Support » Fixing WordPress » Hide div when next_post_link does not return posts

  • Hi,

    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>
    			</div>

    Thanks for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • you add html to the %link section

    rather than:

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

    Use:

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

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide div when next_post_link does not return posts’ is closed to new replies.