I have a Wordpress template with a single.php page. The page has "next" and "previous" arrows to allow navigating through all posts. I want to exclude posts from some categories from being included in the "next" and "previous" calculation. I have this code:
// in single.php
next_post_link( '%link', '← Previous', false, '11 and 13 and 15');
This should show the link to the next post. Posts in categories 11, 13, and 15 should not be considered as per the $ignore_categories parameter.
This works for posts that have only one of the categories listed set, e.g. 15. But posts that additionally have a non-excluded category (like 16 or 23), do not get excluded and they show up as the next post link.
Is this the intended behaviour? It doesn't seem to make sense to me.
Is there anything I can do to change it so a post gets excluded whenever it has one of the excluded categories, short of rebuilding the entire functionality?