• How can I get the Koji single pagination to only provide next and previous links within the category corresponding to this post? Or an alternative is to exclude a specific category from the previous and next links.

    I got as far as realizing this can be done using $in_same_term or $excluded_terms arguments to previous_post_link() and next_post_link(). What I cannot determine is how to use these in the Koji theme to get pagination to only provide links within the current category (or not within a specific category). The following changes to pagination.php does not work: `

    `<nav class=”link-pagination<?php echo $pagination_class; ?>”>

    <?php if ( get_previous_posts_link() ) : ?>
    <?php previous_posts_link( __( ‘← Previous Page’, ‘koji’ ), $excluded_terms = “23”); ?>
    <?php endif; ?>

    <?php if ( get_next_posts_link() ) : ?>
    <?php next_posts_link( __( ‘Next Page →’, ‘koji’ ), $excluded_terms = “23” ); ?>
    <?php endif; ?>

    </nav><!– .posts-pagination –>

Viewing 1 replies (of 1 total)
  • Theme Author Anders Norén

    (@anlino)

    Hi @bbogart,

    pagination.php is used for the archive pagination (with the posts in a grid), not for the single post navigation, so any changes made there won’t affect the next/previous post links. You can find the single post navigation in content.php, starting at line 38 in the latest version.

    There, you would change this:

    // Single pagination
    $next_post = get_next_post();
    $prev_post = get_previous_post();

    To this:

    // Single pagination
    $next_post = get_next_post( true );
    $prev_post = get_previous_post( true );

    Keep in mind though that any changes you make directly to the theme files will be overwritten the next time Koji is updated, so I would recommend that you copy the content.php file to a child theme and make the changes there.

    — Anders

Viewing 1 replies (of 1 total)
  • The topic ‘Pagination within category / with category exclusion’ is closed to new replies.