Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
add an orderby clause to your query. codex.wordpress.org/Function_Reference/… –  keatch Feb 24 '11 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 Feb 26 '11 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 Feb 28 '11 at 0:38
add comment

4 Answers 4

Simply add orderby to your query_posts

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

Update

try:

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.

share|improve this answer
    
I've been trying that, but still no luck :( –  user3472 Feb 24 '11 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 Feb 24 '11 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 Feb 24 '11 at 14:43
    
i updated my answer try it now. –  Bainternet Feb 24 '11 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 Feb 24 '11 at 16:13
show 5 more comments

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.

share|improve this answer
add comment

The cat parameter is partly broken in 3.1.

Install the Hotfix plugin to fix it:

http://wordpress.org/extend/plugins/hotfix/

share|improve this answer
    
sadly, this didn't fix it either. –  user3472 Feb 24 '11 at 21:26
    
Well, in that case, use category__not_in=4 instead. –  Otto Feb 25 '11 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 Feb 27 '11 at 11:33
add comment

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)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.