My pagination is only linking to the same posts that are on my front page.

I have 3 posts on my front page, when I press next it goes to /page/2 but only shows the same 3 posts, with no previous button. The next button is still there, but still goes to page/1

Here is the full query.



            if ( have_posts() ) : while ( have_posts() ) : the_post();

            $category = choose_one_category(get_the_category());

            switch ($category){
                case "Festival News":
                    $left[] = $post;
                case "Industry News":
                    $centre[] = $post;
                case "Other":
                    $right[] = $post;

            <div class="custom-pagination">

            <div ><?php previous_posts_link('&laquo; Previous') ?></div>

            <div ><?php next_posts_link('Next &raquo;') ?></div>
            <?php endif;


4 Answers 4


Building off of what Rarst has said, I'm pretty sure the query string will retain 'paged' queries even if WP_Query strips it out as irrelevant. You could try replacing your query posts line with this:

global $query_string;
parse_str( $query_string, $my_query_array );
$paged = ( isset( $my_query_array['paged'] ) && !empty( $my_query_array['paged'] ) ) ? $my_query_array['paged'] : 1;
  • 1
    YES!! now, any chance you could explain what is happening? So that I and others can understand it? Many thanks
    – Mild Fuzz
    Commented Oct 6, 2010 at 13:16
  • for example, can I use this with custom WP_Query objects? I have a few that are also not working.
    – Mild Fuzz
    Commented Oct 6, 2010 at 13:18

Pagination functions are meant to be used with main Loop. They are relying on global variables $paged and $wp_query, which are not set by your custom loop.

  • how can I correct this?
    – Mild Fuzz
    Commented Oct 6, 2010 at 11:55
  • If this is main content/loop of your page you need to work with query_posts(). Otherwise you might need to code your own pagination, at least I don't know how to make native pagination functions work with secondary loop.
    – Rarst
    Commented Oct 6, 2010 at 11:58
  • I have ammended the above loop. I get a next button, but the posts are those from the front page.
    – Mild Fuzz
    Commented Oct 6, 2010 at 12:22
  • Why shouldn't they be? You are not specifying anything in query except post type and quantity. Also see Preserving original query
    – Rarst
    Commented Oct 6, 2010 at 12:53

If you stumble upon this one, try the following: "Easy Pagination Deamon". Install, activate, use the template tag inside your template...

The link to the stylesheet can be found inside my gists or below the top plugin comment.


Is this on your home page? I had this problem as well and as a workaround, I simply made the link on the first page point to http://www.yoursite.com/category/page/2/ so it skips the first set of values for page one. From there on, the pagination links worked correctly. Here is an example.

  • just a little bit hacky
    – Mild Fuzz
    Commented Oct 6, 2010 at 14:40
  • agreed but in terms of time, it can be a life saver. Last month, I had to build 14 WP sites in 2 weeks and unfortunately, had to resort to hacks for time's sake.
    – moettinger
    Commented Oct 6, 2010 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.