[resolved] Hide div when next_post_link does not return posts (3 posts)

  1. Jeremy Herve
    Posted 5 years ago #


    I have a bit of a problem with styling next_post_link and previous_post_link in single.php.

    I have wrapped both functions in divs, where in each div has a background image (an arrow). That works great, the only problem is, when I am in the latest article, the arrow for the next article is displayed, while there is actually no next article.

    How could I solve that issue?

    Here is my code for the navigation, nothing cimplicated I think:

    <div class="single-nav">
    				<div class="nav-next"><?php next_post_link( '%link' ) ?></div>
    				<div class="nav-previous"><?php previous_post_link( '%link' ) ?></div>

    Thanks for your help!

  2. Rev. Voodoo
    Posted 5 years ago #

    you add html to the %link section

    rather than:

    <div class="nav-next"><?php next_post_link( '%link' ) ?></div>


    <?php next_post_link( '<div class="nav-next"> %link </div>' ) ?>
  3. Jeremy Herve
    Posted 5 years ago #

    Simple solution, works like a charm.
    Thank you very much for your help!!

Topic Closed

This topic has been closed to new replies.

About this Topic