# Why do next pages load the same content rather then older articles?

For some reason, the 'previous posts' and 'next posts' on the homepage do not load previous posts, but rather the same posts that were on the main page.

Why is that? I don't even know where to start debugging...

I have the following code snippets that might be related in the loop.php file:

if ( is_home() ) {
query_posts($query_string . '&cat=-13,'); } while ( have_posts() ) : the_post(); ?> // This following line added to exclude posts that have custom variable ad=true: <?php if ( get_post_meta($post->ID, 'ad', true) == '') {  ?>


...there here are the posts displaying...

<?php } // Ending the exlusion of 'ad' ?>
<?php endwhile; // End the loop. Whew. ?>

<?php if (  $wp_query->max_num_pages > 1 ) : ?> <div id="nav-below" class="navigation"> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Предишни статии', 'twentyten' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'Следващи статии <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div> </div><!-- #nav-below --> <?php endif; ?>  Where else could the problem be, if not in those snippets? How could I debug it? - ## 2 Answers Are you using 'posts_per_page' and 'paged' in the query string? if not try to add $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query .= 'posts_per_page=5&paged='.$paged


Number 5 will be replaced with the number of posts after which you want the next page (pagination) link to show up.

Also remove the if statement on the next page link

if ( \$wp_query->max_num_pages > 1 )

-
Hi, that kind-of-worked. I do indeed get the other articles as pages, but after the second click on the previous posts link, I start getting at the same time "no posts to display + searchbox" AND the continuing articles right below it. very strange –  mgPePe Aug 18 '11 at 12:31
Oh yes, i figured it out - the no posts to display part was before the query. all good now. thanx –  mgPePe Aug 18 '11 at 13:00
@mgPePe: no problem :) –  Sisir Aug 18 '11 at 18:44

It's because your homepage is using it's own query_posts call, and that query_posts call is bringing back all posts from a specific category. Since that is the only restriction in place it will always retrieve and display the same posts.

-
hm, okay, and how do i fix this? –  mgPePe Aug 17 '11 at 16:54