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.
Did you try with:
get_adjacent_post
?wp topic: get_adjacent_posts-exclude-category-syntax
The 2nd parameter enables you to exclude category I.D’s
Source https://codex.wordpress.org/Function_Reference/get_next_post
Same with get_adjacent_post()
In Word.ress 3.9 (and still in 3.9.1) there’s a bug concerning the excluded terms in
get_adjacent_post()
. There’s a plugin to fix that bug.