Forums

query_posts adds improper posts to category archive (2 posts)

  1. firestick13
    Member
    Posted 1 year ago #

    I'm trying to limit the number of posts that show up on a category's archive page. I used query_posts in the category's template file and now posts from different categories are displayed on the category's archive page and too many posts are still being displayed.

    I added this near the top...
    <?php query_posts('showposts=5'); if (have_posts()) : ?>
    and this near the bottom...
    <?php endif; wp_reset_query(); ?>
    and the archive page http://www.social-ecology.org/category/biodev/
    lists 7 posts (not 5) and includes posts that aren't in the biodev category.

    Can anyone tell me what's going on here?
    Thanks!

    -Alec

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    is there a reason why you can't use the setting in 'settings' 'reading' ?

    if there is, try to include the $query_string:
    http://codex.wordpress.org/Function_Reference/query_posts#Usage_Note

    <?php
    global $query_string;
    query_posts( $query_string . "&posts_per_page=5" );
    if (have_posts()) :
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic