I find this code
function previous_posts_from_same_category( $args ) {
$args['in_same_term'] = true;
return $args;
}
add_filter( 'astra_single_post_navigation', 'previous_posts_from_same_category' );
this code allows navigate between the same category, but same child category.
I little more explained:
I have two categories named “parent cat 1” and “parent cat 2”. “parent cat 1” has two subcategories: “child cat 1” and “child cat 2”. the “child cat 1” has one “post 1” and the “child cat 2” has one “post 2”.
“parent cat 2” has only one “post 3”
the tree would be:
parent cat 1
child cat 1 > post 1
child cat 2 > post 2
parent cat 2 > post 3
by default, from every post, there are next and prev buttons, and you can navigate through all post.
with the found code, you can navigate through posts with same category, not the same parent category but the same child category.
if I am in “post 1”, there are no navigation buttons, because the “child cat 1” only have one post.
I would want that when I’m in “post 1” (which belongs to “parent cat 1”) I could navigate to “post 2”, but not to “post 3”.
can it be possible…?
many thanks