Conditional tag for next/previous posts? (2 posts)

  1. FekketCantenel
    Posted 9 years ago #

    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.

  2. moshu
    Posted 9 years ago #

    next_post and previous_post are used on single post view (=single.php) and they do that by default:

Topic Closed

This topic has been closed to new replies.

About this Topic