Title: Hide div when next_post_link does not return posts
Last modified: August 19, 2016

---

# Hide div when next_post_link does not return posts

 *  Resolved [Jeremy Herve](https://wordpress.org/support/users/hd-j/)
 * (@hd-j)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/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)

 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/hide-div-when-next_post_link-does-not-return-posts/#post-1862825)
 * 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>' ) ?>
       ```
   
 *  Thread Starter [Jeremy Herve](https://wordpress.org/support/users/hd-j/)
 * (@hd-j)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/hide-div-when-next_post_link-does-not-return-posts/#post-1863033)
 * 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.

## Tags

 * [navigation](https://wordpress.org/support/topic-tag/navigation/)
 * [next_post_link](https://wordpress.org/support/topic-tag/next_post_link/)
 * [previous_post_link](https://wordpress.org/support/topic-tag/previous_post_link/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Jeremy Herve](https://wordpress.org/support/users/hd-j/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/hide-div-when-next_post_link-does-not-return-posts/#post-1863033)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
