I am using a theme called Avada a fairly well known theme. By default wordpress if you have more than one category for posts and have prev/next nav on for the posts wordpress will run thru all the posts and not keep them in same taxonomy. I figured code for another theme to make the prev/next stay in the same taxonomy but am having trouble making this work. Does anyone have some code for the functions php or single post php that would achieve this for wordpress in general? They're used to be a plugin for this but it's way out date. Thanks.
I am using a theme called Avada a fairly well known theme. By default wordpress if you have more than one category for posts and have prev/next nav on for the posts wordpress will run thru all the posts and not keep them in same taxonomy. I figured code for another theme to make the prev/next stay in the same taxonomy but am having trouble making this work. Does anyone have some code for the functions php or single post php that would achieve this for wordpress in general? They're used to be a plugin for this but it's way out date. Thanks.
There's a decent stack of functions here:
next_post_link()
get_next_post_link()
get_adjacent_post_link()
get_adjacent_post()
Unfortunately, within this stack of functions, there aren't any filters that are intended to change the $in_same_term
parameter.
Probably the best approach would be to create a child theme and override the single.php
file within the child theme, and change the parameters of next_post_link()
and previous_post_link()
to set the $in_same_term
parameter to true
.