WordPress.org

Support

Support » Themes and Templates » Display next post link only if there is a next post

Display next post link only if there is a next post

  • Howdy all,

    I’ve got a slight problem with my next post / previous post links. I want to wrap them in some generic markup, such as an
    <.li>, but when a user is on the most recent post, I don’t want the “next post”

    <?php if (next_post_link()) { ?>
    <.li>Next: <?php next_post_link(); ?><.li>
    <?php } ?>

    Unfortunately this spits out the next post link once it gets to the if statement, rather than evaluating the if statement, then applying what’s in between the brackets. Forgive my ignorance of php, but is there an easy way to accomplish this that I’m missing?

    Any help would be greatly appreciated!

    (forgive the “.” before the li tags, the forum wants to parse those even if I encode them :-p )

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display next post link only if there is a next post’ is closed to new replies.