WordPress.org

Ready to get started?Download WordPress

Forums

Trouble with query_posts (3 posts)

  1. adamrice
    Member
    Posted 6 years ago #

    I'm working on a custom theme, and want to generate archive pages showing all entries for the selected time period or category one one page, no pagination. The codex helpfully provides this code sample:

    <?php
    query_posts($query_string.'posts_per_page=-1');
    while(have_posts()) { the_post();
    <!-- put your loop here -->
    }
    ?>

    This is not working according to plan. Date archives behave as before: paginated. Category archives (which are generated from the same template) do not produce any output for the loop. I've even borrowed the "archive.php" file from the default template, added the line query_posts($query_string.'posts_per_page=-1'); to it, and gotten the same results.

    thanks in advance for any help.

  2. adamrice
    Member
    Posted 6 years ago #

    bump

  3. Anonymous
    Unregistered
    Posted 5 years ago #

    It seems the documentation on the query_posts page regarding using $query_string is incomplete. I'm doing something similar to what you're doing and after several unsuccessful attempts, I tried simply printing out the $query_string variable to see what was in it and it's either empty or it doesn't exist.

    The following code produces no output:

    <?php
    echo $query_string;
    print_r($query_string);
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic