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('« Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></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 toquery_posts()
.How can I display the navigation links?
Thanks.
- The topic ‘Query Posts and Navigation’ is closed to new replies.