Support » Fixing WordPress » Problem with 'Older Entries" link.

  • Resolved milktheman


    I’m having what seems like a fairly common problem, however I can’t resolve my issue with the advise in other resolved threads.

    I have a blog-homepage template that is set to display 5 posts. When I click the ‘older entries’ link (or ‘newer entries’) the returned page/2, page/3, etc, displays the same 5 most recent posts.

    Here is everything between my div that holds the post’s content and the footer:

    <?php query_posts("posts_per_page=5"); ?>
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    	<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    	<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    	<?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>
    	<div class="entry">
    	<?php the_content(); ?>
    	<div class="postmetadata">
    	<?php comments_popup_link('No Comments »', '1 Comment »', '%        Comments »'); ?>
    	<?php endwhile; ?>
    	<?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>
    	<?php else : ?>
    	<h2>Not Found</h2>
    	<?php endif; ?>

    I have also tried disabling all plug-ins to test for compatibility.

    Any hints would be fantastic. Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must include the ‘paged’ argument to query_posts in order for pagination to work. Try changing this:

    <?php query_posts("posts_per_page=5"); ?>

    to this:

    <?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
    query_posts("posts_per_page=5&paged=$paged"); ?>

    THANKS! That’ll do it. I appreciate the help. Now I’m going to look up why that works so I don’t forget to do that in the future.

    If your problem has been solved, please use the dropdown on the right to mark this topic ‘Resolved’ so that anyone else with this question can see that there is a solution.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem with 'Older Entries" link.’ is closed to new replies.