The first posts I wrote are now showing on the homepage. After Googling, the problem is because I am using query_posts to exclude a certain category on the main loop.

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

how can I still exclude this category, but not have my posts reversed?

  • add an orderby clause to your query. codex.wordpress.org/Function_Reference/…
    – keatch
    Commented Feb 24, 2011 at 13:02
  • I have this issue too. I've removed the category exclusion but it is still a problem. I've set the theme to Twenty Ten but it is still a problem so it doesn't even seem to be a theme problem. I've set the permalinks back to default but it is still a problem. I'm at a loss and besides this note from John there doesn't seem to be anyone else affected by this problem. It is definitely as a result of upgrading to 3.1 though. Another point too is my email subscription through Feedburner included a bunch of my very first posts in the email message the day after I upgraded to 3.1 as i
    – user3527
    Commented Feb 26, 2011 at 8:24
  • 1
    What version of MySQL is your system running? There was a problem about 3 years back with specific versions of MySQL being a problem: wordpress.org/support/topic/…
    – Otto
    Commented Feb 28, 2011 at 0:38

4 Answers 4


Simply add orderby to your query_posts

<?php query_posts($query_string . '&cat=-4&orderby=date&order=DESC'); ?>



global $wp_query;
$args = array_merge( $wp_query->query, array('cat' => -4,'orderby' => 'date','order' => 'ASC'));
query_posts( $args );

and if you still get the same change ASC to DESC.

  • I've been trying that, but still no luck :(
    – user3472
    Commented Feb 24, 2011 at 13:57
  • Originally I tried '&cat=-4&order=DESC' and then I tried reversing it 'order=DESC&cat=-4' when I use your code, it's still not working. Must be a change in Wordpress 3.1?
    – user3472
    Commented Feb 24, 2011 at 14:01
  • No, 3.1 query_posts is still the same with a few added features, one i'll get home i'll take a crack at this again.
    – Bainternet
    Commented Feb 24, 2011 at 14:43
  • i updated my answer try it now.
    – Bainternet
    Commented Feb 24, 2011 at 15:17
  • 2
    The query is just fine and i've tested it using the theme you linked on 3.1 , try disabling your plugins and see if one of them is causing this
    – Bainternet
    Commented Feb 24, 2011 at 16:13

DING DING DING. As Otto pointed out, the problem is because the MYSQL version I'm running is 5.0.51a which is causing the bug.


The cat parameter is partly broken in 3.1.

Install the Hotfix plugin to fix it:


  • sadly, this didn't fix it either.
    – user3472
    Commented Feb 24, 2011 at 21:26
  • Well, in that case, use category__not_in=4 instead.
    – Otto
    Commented Feb 25, 2011 at 17:05
  • category__not_in didn't solve it either. I tried these 2 just right now: <?php query_posts($query_string . '&category__not_in=4&orderby=date&order=DESC'); ?> --- and <?php query_posts($query_string . '&category__not_in=4'); ?>
    – user3472
    Commented Feb 27, 2011 at 11:33

I just encountered this issue as well when upgrading a staging site to WordPress 3.1 (from 3.0.1).

The hotfix plugin didn't fix the issue.

I fixed it by upgrading MySQL to version 5.1.40 (from 5.0.51b)

Your Answer

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