- This topic has 13 replies, 3 voices, and was last updated 4 years, 11 months ago by
Tom.
-
AuthorPosts
-
November 17, 2020 at 9:51 am #1535068
Cris
Hi
I use CPT configured to show the post navigation as you indicate here. It worked fine when I did it a long time ago but now, the “previous post” and “next post” links are displayed in duplicate. Any idea why this happens?
November 17, 2020 at 12:01 pm #1535199Leo
StaffCustomer SupportHi there,
Good question – I think that’s because we’ve included the post navigation in the footer entry meta.
What happens if you remove that code? Does it remove both of them?
Let me know 🙂
November 17, 2020 at 12:13 pm #1535230Cris
Hi Leo,
Yes! If I delete the code, both of them disappear
November 17, 2020 at 2:07 pm #1535338Leo
StaffCustomer SupportCan you try add this snippet as well?
add_filter( 'generate_footer_entry_meta_items ', function( $items ) { if ( is_singular( 'your-post-type' ) ) { return; } return $items; } );November 18, 2020 at 12:13 am #1535642Cris
It does not work.
November 18, 2020 at 9:22 am #1536491Leo
StaffCustomer SupportEdited the code above. Can you give it another shot?
Make sure to edit
your-post-typeNovember 18, 2020 at 12:30 pm #1536700Cris
Thanks Leo but it doesn’t work either.
I don’t forget to edit “your-post-type” 🙂
November 18, 2020 at 1:58 pm #1536763Tom
Lead DeveloperLead DeveloperInstead of the original function you linked to, do this:
add_filter( 'generate_footer_meta_post_types', function( $post_types ) { $post_types[] = 'your-post-type'; return $post_types; } ); add_filter( 'generate_footer_entry_meta_items ', function( $items ) { if ( is_singular( 'your-post-type' ) ) { return array( 'post-navigation', ); } return $items; } );November 19, 2020 at 12:24 am #1537135Cris
Hello Tom
If I replace the original, all the previous and next links disappear.
If I add it after the original, there are no changes.November 19, 2020 at 9:37 am #1537932Tom
Lead DeveloperLead DeveloperCan you try the updated functions?: https://generatepress.com/forums/topic/duplicate-post-navigation-in-cpt/#post-1536763
November 19, 2020 at 10:30 am #1537971Cris
Now yes, Tom! Thanks a lot.
One last thing. For 2 or more CPTs, do I have to duplicate the function?
November 19, 2020 at 7:34 pm #1538357Tom
Lead DeveloperLead DeveloperNope, you can do this:
add_filter( 'generate_footer_meta_post_types', function( $post_types ) { $post_types[] = 'your-post-type'; $post_types[] = 'another-post-type'; $post_types[] = 'one-more'; return $post_types; } ); add_filter( 'generate_footer_entry_meta_items ', function( $items ) { $post_types = array( 'my-post-type', 'another-post-type', 'one-more' ); if ( is_singular( $post_types ) ) { return array( 'post-navigation', ); } return $items; } );Hope this helps 🙂
November 19, 2020 at 11:54 pm #1538511Cris
Perfect! Many thanks to the whole team.
You do a spectacular job.November 20, 2020 at 9:04 am #1539192Tom
Lead DeveloperLead DeveloperGlad we could help 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.