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

  1. Tomas Mackevicius
    Posted 5 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:


    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
    Posted 5 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
    Posted 5 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:


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

    Perhaps reference to:


    could be added or the code:

    if (is_home()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

Topic Closed

This topic has been closed to new replies.

About this Topic