WordPress.org

Ready to get started?Download WordPress

Forums

Pagination with query_posts (4 posts)

  1. Lasha
    Member
    Posted 4 years ago #

    I literally tried everything I could think of, and every solution the WordPress Codex gave to preserve pagination when using query_posts. Nothing worked.

    http://codex.wordpress.org/Function_Reference/query_posts#Example_3 (read Example 3 and "preserving the original query")

    A page would only show the 1st page of results, and clicking "next" or going to page/2 would throw a 404. Is this some kind of bug in 3.0.1 where the documented query preserving doesn't work?

    Crazy workaround: I used a Page with a custom template where I defined my own $wp-query with a bunch of parameters, and pagination worked beautifully.

    This workaround DOES NOT fix the original problem. Any ideas?

  2. westondeboer
    Member
    Posted 4 years ago #

    you need to have this in your query

    $wp_query->query('showposts=5'.'&paged='.$paged);

    so in example 3 it would be:

    <?php
    query_posts($query_string.'&posts_per_page=-1'.'&paged='.$paged);
    while(have_posts()) { the_post();
    <!-- put your loop here -->
    }
    ?>
  3. Lasha
    Member
    Posted 4 years ago #

    Is that solution tested?

    I don't see how adding that &paged=$paged would help. The "$query_string" should already have that value within it so there's no point to call &paged again...

    Thanks!!

  4. Expenses
    Member
    Posted 4 years ago #

    Yep i think the solution do work. thanks

Topic Closed

This topic has been closed to new replies.

About this Topic