function to prevent posts of certain category from appearing in prev/next
-
Hi everyone, I have posts within a certain category that are purposely hidden from search engines, and we don’t want the posts within that category to appear within the sequential previous/next navigation that appears on the other posts.
I’m using a child theme of Genesis that has a master switch to turn off all previous/next navigation, which is what I’ve done for the interim. But the ideal solution would be to have a function that expressly excludes posts from that category, and then we could safely turn the prev/next nav back on.
After much searching I’ve not found a ready made function to solve this, so am having to cobble something together, which I’ m not 100% comfortable with, so would appreciate some coaching.
I have found this code snippet, referencing uncategorized posts. It was written for Divi (found through a Reddit forum here), but could it work for any theme, provided I swap out the slug name for my category name?
This is for a very large, live site, so I’m reluctant to chuck random code off the internet before getting some counsel first. Or perhaps there is a better way entirely of writing a function that would serve the purpose.
Thanks for any insights.
- You must be logged in to reply to this topic.