• keempoo

    (@keempoo)


    Absolutely love this theme for a portfolio site!

    Is it possible to get some input on how you would best change the pagination code so that the most recent post (“/girls-girls-girls”) would show both the “next post” (the second latest post) as well “the previous post” (which would be the earliest post). It currently only shows the “Next Post”

    Eskell’s pagination code:

    // The pagination links also work as a no-js fallback, so they always need to be output.
    $prev_link = get_previous_posts_link( ‘<span class=”arrow stroke-cc”>’ . eksell_get_theme_svg( ‘ui’, ‘arrow-left’, 96, 49 ) . ‘</span><span class=”screen-reader-text”>’ . esc_html__( ‘Previous Page’, ‘eksell’ ) . ‘</span></span>’, $query_args[‘max_num_pages’] );
    $next_link = get_next_posts_link( ‘<span class=”screen-reader-text”>’ . esc_html__( ‘Next Page’, ‘eksell’ ) . ‘</span></span><span class=”arrow stroke-cc”>’ . eksell_get_theme_svg( ‘ui’, ‘arrow-right’, 96, 49 ) . ‘</span>’, $query_args[‘max_num_pages’] );

    if ( $prev_link || $next_link ) :
    $pagination_class = ! $prev_link ? ‘ only-next’ : ( ! $next_link ? ‘ only-previous’ : ” );
    ?>

    <nav class=”link-pagination<?php echo esc_attr( $pagination_class ); ?>”>

    <?php if ( $prev_link ) : ?>
    <div class=”previous-wrapper”>
    <?php echo $prev_link; ?>
    </div><!– .previous-wrapper –>
    <?php endif; ?>

    <?php if ( $next_link ) : ?>
    <div class=”next-wrapper”>
    <?php echo $next_link; ?>
    </div><!– .next-wrapper –>

    The page I need help with: [log in to see the link]

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

    (@anlino)

    Hi @keempoo,

    I’m glad you like it! I assume you mean the post navigation shown when you’re viewing a single post, correct?

    There’s no easy way to accomplish this, unfortunately. In simple terms, you’d have to update single-post-navigation.php to check if either $nav['prev'] or $nav['next'] is false, and then get either the most recent post in the chronology (for the previous link) or the oldest (for the next link).

    This plugin could be useful to simplify the custom code needed: https://www.ads-software.com/plugins/loop-post-navigation-links/

    — Anders

Viewing 1 replies (of 1 total)
  • The topic ‘Continuous Loop for “Previous” and “Next” Posts’ is closed to new replies.