Support » Fixing WordPress » blog pagination problem

  • Resolved blicht454

    (@blicht454)


    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!

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi

    (@esmi)

    Forum Moderator

    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

    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; ?>
    esmi

    (@esmi)

    Forum Moderator

    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);
    ?>

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

    esmi

    (@esmi)

    Forum Moderator

    Glad I could help 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘blog pagination problem’ is closed to new replies.