WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] blog pagination problem (6 posts)

  1. blicht454
    Member
    Posted 2 years ago #

    Hello, I'm running into a very strange problem with the blog pagination on my site. When clicking "older posts" I'm taken to /blog/page/2 but it's showing the same posts as the first page of blog entries.

    You can see the site here.

    Does anyone have any ideas of why this is happening and how I can fix it?

    Thanks!

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    It's almost certainly the result of a poorly coded custom query in your theme's index.php template file. See http://codex.wordpress.org/Function_Reference/query_posts

  3. blicht454
    Member
    Posted 2 years ago #

    Yeah, that much I figured. Can you take a look at my code for the query and see if you notice anything strange? I'm not really customizing the loop all that much.

    <?php query_posts('posts_per_page=3'); ?>
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                   ~the post is here~
    <?php endwhile; ?>
    		<div id="blog-nav">
    			<div id="older-posts"><?php next_posts_link('<span class="little-arrow-two-right"></span>older') ?></div>
    			<div id="newer-posts"><?php previous_posts_link('<span class="little-arrow-two-left"></span>newer') ?></div>
                   </div>
    <?php else : ?>
    	<h2>Not Found</h2>
    <?php endif; ?>
  4. esmi
    Forum Moderator
    Posted 2 years ago #

    Change:
    <?php query_posts('posts_per_page=3'); ?>

    to:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'posts_per_page' => 3,
    	'paged' => $paged
    );
    query_posts($args);
    ?>
  5. blicht454
    Member
    Posted 2 years ago #

    Brilliant! Thanks so much. It's working great now!

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    Glad I could help :-)

Topic Closed

This topic has been closed to new replies.

About this Topic