WordPress.org

Support

Support » Themes and Templates » Conditional tag for next/previous posts?

Conditional tag for next/previous posts?

  • I’m not very good with PHP, so I can’t ascertain it from the source itself. Can someone please tell me: what should I use as an ‘if’ when checking to see if there’s a previous/next post?

    This is something like the code I’d like to use:


    <?php if(!$post->post_previous) {
    next_post('%','Next &raquo;', 'no');
    } else if(!$post->post_next) {
    previous_post('%','&laquo; Previous', 'no');
    } else {
    previous_post('%','&laquo; Previous', 'no'); :; next_post('%','Next &raquo;', 'no');
    } ?>

    Pretty much, if there is a previous post but no next post, show only the previous; if there’s a next but no previous, show only the next; if there are both next and previous posts, show both with a : seperator. I hope this is clear enough, because I’m afraid I’ve muddled the question up too much.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Conditional tag for next/previous posts?’ is closed to new replies.
Skip to toolbar