I have a custom post type called “exhibitions” that uses the native “category” taxonomy. I have three categories: Current, Past, and Featured. Posts get marked either Current or Past and some are also marked as Featured.
I want my next/prev links on single pages to exclude the ‘featured’ category (tag_ID=21) so that my current and past posts don’t cross over when users are using post navigation, but I can’t seem to get this to happen. I have tried:
get_next_post(true,'21')
, get_next_post(false,'21')
and pretty much every other permutation of arguments, but my Past/Featured posts continue to show up adjacent to my Current/Featured posts in the post navigation.
3 Answers
Did you try with: get_adjacent_post
?
get_adjacent_post(false, 'YourID', false);
wp topic: get_adjacent_posts-exclude-category-syntax