Forums

Conditional previous_post and next_post (3 posts)

  1. mr orange
    Member
    Posted 7 months ago #

    I would like to display a filler in the spot if there is no next post and/or previous post. So that when you click on the first link, there is a special "filler" div displaying a dash or something to signify that something belongs in that spot.

    Does that make sense?

    Does anyone know a conditional code to check if there is a next post and "else {" put something else?

    Here is my current code:

    <div class="prevlink"><?php previous_post('%','Previous Post<br></a><span style="font-weight: normal">', 'yes');?></div>
            	   		 <div class="nextlink"><?php next_post('%','Next Post<br></a><span style="font-weight: normal">', 'yes');?></div>

    I want to add <div class="filler">&mdash;</> if there is no prev or next post link

    Thanks!!

  2. NateJacobs
    Member
    Posted 7 months ago #

    You could use get_next_post() in an if statement to test if there is a next post. If yes, display next post link using next_post_link() ( side note next_post() and previous_post() are both deprecated ) otherwise display your filler div.

  3. alchymyth
    The Sweeper
    Posted 7 months ago #

Reply

You must log in to post.

About this Topic