for the default next/prev pages links get_the_post_navigation() or previous_post_link() / next_post_link(), they’ve all got an arg in_same_term
that’d do that for you.
Hi! I did change to link-template.php in_same_term to be true (code below) but still its not working. Did i do it wrong?
function get_previous_post( $in_same_term = true, $excluded_terms = ”, $taxonomy = ‘category’ ) {
return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy );
}
function get_next_post( $in_same_term = true, $excluded_terms = ”, $taxonomy = ‘category’ ) {
return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy );
}
sorry, I should of mentioned you should be editing your theme, not core WordPress files. Your theme is in poseland/wp-content/themes/oceanwp/
It appears that your theme oceanwp
has the single post navigation setup in the file partials/single/next-prev.php
– however it does correctly have 'in_same_term' => true,
set – which is interesting.
It seems to be a really customizable theme and has a user option to use the TAG or the CATEGORY for next/prev, and on a default setup, it’s using the TAG by default (not the CATEGORY).
So, to change it, open your WordPress Dashboard, go to Apperances > Customizer > Blog > Single Post
, there’s an option Next/Prev Taxonomy, change it from TAG
to CATEGORY
and you should be set.
Thank you so much!! That really did the trick! 😀