Title: Adding posts_nav_link() to theme
Last modified: August 19, 2016

---

# Adding posts_nav_link() to theme

 *  Resolved [guided](https://wordpress.org/support/users/guided/)
 * (@guided)
 * [16 years ago](https://wordpress.org/support/topic/adding-posts_nav_link-to-theme/)
 * I’m struggling to add posts_nav_link() to index.php. I get no error message, 
   but nothing the nav links don’t appear. What am I missing?
 * My code looks like this:
 *  `<?php endwhile; else: ?>
    <?php posts_nav_link(); ?> <? // php _e(‘Sorry, no
   posts matched your criteria.’); ?> <?php endif; ?>`
 * The theme I’m using did not have posts_nav_link(); beforehand, perhaps because
   it has the following just before the endwhile:
 *  `<p class=”post-footer align-right”>
    ” rel=”bookmark” class=”readmore”>Read
   more
   
    ” class=”comments”><?php comments_number(‘No Comments’, ‘Comments (1)’,‘
   Comments (%)’ );?>
   
    <span class=”date”><?php the_time(‘M j, Y’); ?></span> <?
   php if ((function_exists(‘get_the_tags’)) ) { the_tags(); } ?></p>`
 * Thats just a guess. Any ideas? Site is [oldworldwandering.com](http://www.oldworldwandering.com)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [16 years ago](https://wordpress.org/support/topic/adding-posts_nav_link-to-theme/#post-1482492)
 * the position you put the posts_nav_link() in is only used if there are no posts.
 * move the posts_nav_link() to just **before **‘endwhile;’
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years ago](https://wordpress.org/support/topic/adding-posts_nav_link-to-theme/#post-1482493)
 * Try using:
 *     ```
       <?php endwhile; ?>
       <?php posts_nav_link(); ?>
       <?php else:?>
       ```
   
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [16 years ago](https://wordpress.org/support/topic/adding-posts_nav_link-to-theme/#post-1482528)
 * go with [@esmi](https://wordpress.org/support/users/esmi/)’s suggestion
 *  Thread Starter [guided](https://wordpress.org/support/users/guided/)
 * (@guided)
 * [16 years ago](https://wordpress.org/support/topic/adding-posts_nav_link-to-theme/#post-1482551)
 * Esmi’s fix worked. Makes sense too. Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Adding posts_nav_link() to theme’ is closed to new replies.

## Tags

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

 * 4 replies
 * 3 participants
 * Last reply from: [guided](https://wordpress.org/support/users/guided/)
 * Last activity: [16 years ago](https://wordpress.org/support/topic/adding-posts_nav_link-to-theme/#post-1482551)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
