• hi

    when moving from one post to another using the next and previous buttons, would it be possible, if there are subcategories, only browse the posts in the same parent category?

    many thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter kaquna

    (@kaquna)

    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

    Hi @kaquna,

    ?Unfortunately, this is can’t be done. I am really sorry for the inconvenience you may have because of this.

    Please do let us know if there’s anything else we can help you with.

    ??Have a nice day and stay safe!

    ??Kind regards,
    ?Herman ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘navigate posts in same category’ is closed to new replies.