I've encountered some issues on a clients site since upgrading to WP 3.1.2, and have this evening updated to version 3.1.3, only to find that the problems still persist.


The website is for a local animal shelter, and each post represents a different animal that lives at the shelter. There are a number of categories that specifically relate to the type of animal, such as dogs, cats, horse as well as a "recently adopted" and an "old friends" category. Those last two categories were excluded from the full post list (under 'Meet The Gang' in the navigation) using the following code:

<?php query_posts($query_string . '&cat=-10,-12'); ?>

The upgrade to WordPress 3.1.2 (or the accompanying database update, I'm not sure which) made this code redundant, and the excluded posts began appearing in the 'Meet The Gang' section. I enquired about the issue on WordPress.org, and the following fix was suggested:


Replace the following in your theme's index.php

<?php query_posts($query_string . '&cat=-10,-12'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>


<?php query_posts('cat=-10,-12'); ?>
<?php if ( have_posts() ) : while  ( have_posts() ) : the_post(); ?>

and you should be good.

Unfortunately this resulted in another issue, displaying the posts from page one of the list on page two also (you can see what I mean if you go to the site). I've tried multiple pagination plugins with no success. Regardless of what page you're on, only the first ten animals are displayed.

My client has been really good regarding this issue, but it's been going on for weeks now, and I really need to get it solved. Hoping someone can help me out. :-)

  • just checking: are you using global $query_string; before the query? alternatively, you could try: <?php query_posts('cat=-10,-12&paged='.get_query_var('paged')); ?>
    – Michael
    Commented May 26, 2011 at 11:41
  • @Michael please add that as an answer so it can be voted on and/or accepted
    – Rarst
    Commented May 30, 2011 at 20:00

2 Answers 2


are you using global $query_string; before the query? so that the full line looks like:

<?php global $query_string; query_posts($query_string . '&cat=-10,-12'); ?> 

alternatively, you could try:

<?php query_posts('cat=-10,-12&paged='.get_query_var('paged')); ?>

Your query_posts() should also contain information about the page you are on, for example by passing the paged parameter.

But doing your own query_posts() with paging is a recipe for problems. WordPress already does a query for you, it's better to change this query. Otherwise it is possible that WordPress finds more or less posts than your query, which will mess up paging.

Can you explain how your Meet the gang page works? Is is a Page with a special template that loads the posts? Or do you work with a static front page and is this the posts page? I would hook into pre_get_posts and add the correct category part of the query there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.