Title: Query Posts and Navigation
Last modified: August 19, 2016

---

# Query Posts and Navigation

 *  Resolved [drphil9001](https://wordpress.org/support/users/drphil9001/)
 * (@drphil9001)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/query-posts-and-navigation/)
 * I have a separate blog template (blog.php) to show posts in my blog and a static
   home page (home.php) that seems to be working. However, as I was testing the 
   paging of multiple posts, I noticed that the navigation links within The Loop
   do not show up properly when I reduce the number of posts shown on a page.
 * Here is how I am setting up The Loop on blog.php
 *     ```
       <?php $blog_query = new WP_Query('posts_per_page=1'); ?>
       <?php if ($blog_query->have_posts()) : ?>
   
       <?php while ($blog_query->have_posts()) : $blog_query->the_post(); ?>
       ```
   
 * After the `endwhile` I have the following to setup the navigation links to the
   next page:
 *     ```
       <div class="navigation">
       <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
       <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
       </div>
       ```
   
 * When I view my blog page, I see a single post, but the navigation links do not
   show up. All that is there are empty div tags.
 * I have also tried to replace the instantiation of WP_query class with a `query_posts()`
   call, but when I do that the blog.php page stops rendering at the point of the
   call to `query_posts()`.
 * How can I display the navigation links?
 * Thanks.

Viewing 1 replies (of 1 total)

 *  Thread Starter [drphil9001](https://wordpress.org/support/users/drphil9001/)
 * (@drphil9001)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/query-posts-and-navigation/#post-669114)
 * I finally found the problem. It appears as though there is a bug when you have
   a template and a WP Page with the same name that uses query_posts() and next_post_links()
   or previous_post_links().
 * WP gets confused and those links are broken.
 * A simple rename of the template (not the file name, but rather the template name
   in the file comments) fixes the problem.

Viewing 1 replies (of 1 total)

The topic ‘Query Posts and Navigation’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [drphil9001](https://wordpress.org/support/users/drphil9001/)
 * Last activity: [18 years, 5 months ago](https://wordpress.org/support/topic/query-posts-and-navigation/#post-669114)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
