• I am utilizing the following code to navigate between posts:

    <?php next_post('%', 'Next Game', 'no'); ?>

    The problem is, when it get’s to the last post it is empty. How can I loop it back to the first post??

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    next_post() is a deprecated function, try next_post_link()

    <?php next_post_link('%link', 'Next Game'); ?>

    to show a previous post link use previous_post_link()

    <?php previous_post_link('%link', 'Previous Game'); ?>

    Thread Starter bremmerm

    (@bremmerm)

    Okay – Thanks for the tip. But same problem, when it reaches the last post, the next post is empty. I need to go back to the first post not in reverse(previous post).

    Moderator keesiemeijer

    (@keesiemeijer)

    This checks if there is a next game post, and if there isn’t one it links back to the latest post:

    <?php
    $next = get_adjacent_post( false, '', true );
      if(!$next){
        $latest_post = get_posts('posts_per_page=1');
        if($latest_post) {
          echo '<span class="nav-previous"><a rel="first" href="'.get_permalink($latest_post[0]->ID).'">First Game</a></span>';
        }
      }
    ?>

    Thread Starter bremmerm

    (@bremmerm)

    Hmmm, i tried out the code but did not work..

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Next Post Link – End of posts’ is closed to new replies.