Solution to WordPress Page navigation showing same list of posts

Do you have questions some what similar to below:

I have my blog setup so that 10 posts show per page but when I click on next page, the same 10 posts appear. How do I get it to show my older posts?

The page navigation most of the time does not work in customized wordpress theme. Moreover specially in home page it doesn’t work. I also encountered with the same problem while creating a new WordPress Theme. My wordpress template uses more than one query_posts.

First I tried with following technique:


$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

query_posts('paged=$paged');

But still the problem persisted because I’ve called query_posts more than once, that’s why it mess up the pagination.

Later I found a new solution for this. i.e. reseting the query_posts.

To reset the query_posts, wordpress has default function wp_reset_query();.

This resets the query_posts. If you have more than one posts loop in your wordpress theme, apply this function after the end of the loop.


<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>

<?php query_posts('&paged=$paged');

while (have_posts()) : the_post(); ?>

<?php the_title(); ?>

<?php the_content(); ?>

<?php endwhile; ?>

<?php wp_reset_query(); ?>

Reset query after calling query_posts function every time. You’ll have the problem solved then.

You can leave a response, or trackback from your own site.

Leave a Reply