• ericbullet

    (@ericbullet)


    Forgive me if this question is beyond the scope of support… I just really admire your themes and I’m attempting to teach myself more advanced theme development.

    Is it possible to set the prev/next pagination to only show topics from the same category?

    I can see in pagination.php

    
    $has_previous_link = get_previous_posts_link();
    $has_next_link = get_next_posts_link();
    

    After some research it seems as if changing those lines to add parameters would work:

    
    $has_previous_link = get_previous_posts_link( $in_same_term = true, $taxonomy = 'category' );
    $has_next_link = get_next_posts_link( $in_same_term = true, $taxonomy = 'category' );
    

    However, that doesn’t seem to do it. So, to reiterate…
    How can I set the prev/next pagination to only show topics from the same category?

    If this is out of scope consider this a feature request for customizer.
    Thanks

    • This topic was modified 3 years ago by ericbullet.
    • This topic was modified 3 years ago by ericbullet.
Viewing 1 replies (of 1 total)
  • Theme Author Anders Norén

    (@anlino)

    Hi @ericbullet,

    get_previous_posts_link() and get_next_posts_link() only accepts the $label argument, for the “Previous/next page link text”. The function you link to is get_previous_post_link() (singular), which is used to link to the previous post on the page for a single post.

    Chaplin outputs the single post navigation in the function chaplin_maybe_output_single_post_navigation() in template-tags.php, which calls the Core function the_post_navigation() which also has an argument for $in_same_term.

    Keep in mind that any changes you make directly to the Chaplin theme files will be overwritten the next time Chaplin is updated. If you want to retain the changes after updates, you should make them in a child theme.

    — Anders

Viewing 1 replies (of 1 total)
  • The topic ‘Limit Next & Previous on Single Post page to same category’ is closed to new replies.