WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Excluding category from the loop prevents paged index (3 posts)

  1. Tomas Mackevicius
    Member
    Posted 3 years ago #

    OK, after doing many experiments I though that something there is fishy, so I decided to do it with default TwentyTen theme.

    Following instructions at:

    http://codex.wordpress.org/The_Loop

    I inserted:

    <?php if ( is_home() ) {
    query_posts($query_string . '&cat=-3');
    }
    ?>

    right before:

    <?php while ( have_posts() ) : the_post(); ?>

    Result: you click "Older posts" and each next page (2,3,4...) shows the same posts.

    Is it a bug or I don't understand something? :-/

    Thanks for the help!

  2. fonglh
    Member
    Posted 3 years ago #

    You have to include the 'paged' parameter to query_posts. To pass it the current page it's on, use get_query_var('paged')

  3. Tomas Mackevicius
    Member
    Posted 3 years ago #

    Thank you very much, fonglh!

    If any admins would read this post, it would be nice to include this info to a loop description to a "Exclude category" section:

    http://codex.wordpress.org/The_Loop

    I don't imagine who would want to exclude category at the same braking the pagination.

    Perhaps reference to:

    http://wordpress.org/support/topic/custom-theme-problem?replies=9%29

    could be added or the code:

    <?php
    if (is_home()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-3&paged=$paged");
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic