I'm trying to show the latest posts using the get_query_var function. The function filters the posts according to their category. When I'm displaying the posts on the page they appear unsorted although I've added the

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
'category__in'=>array( $cat),
'order' => ASC,
'caller_get_posts' => 1,
'orderby' => date,

How can I sort properly?

  • im using wordpress with buddypress
    – peroxide
    Commented Oct 27, 2010 at 9:34
  • Hi Jan, i fixed the orderby but it still doesnt work. here is the code. paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args=array( 'category__in'=>array( $cat), 'order' => ASC, 'caller_get_posts' => 1, 'paged'=>$paged, 'orderby' => date, ); query_posts($args);
    – peroxide
    Commented Oct 27, 2010 at 9:51
  • @peroxide: I've added your update to the question, but you can do this yourself too. You use the paged parameter to control paging, but that should have no effect on sorting. This should be done by the order and orderby parameters (and even if you leave it out, ordering by date is the default). Are you sure no other query is running before you display the posts? Can you give the code up and including the have_posts() and related lines? In what file did you place this code?
    – Jan Fabry
    Commented Oct 27, 2010 at 10:22
  • 1
    @peroxide: No, I have tried it with the regular WordPress, not BuddyPress. I have never used BuddyPress, but I can't imagine it would do something with the sorting of query_posts(). Maybe another plugin? Have you tried disabling all plugins, to see whether one of them hooks into the query and changes settings? Is the order always different (random)? Or is it by ID, by title, ...? Is this an on-line example that we can access?
    – Jan Fabry
    Commented Oct 28, 2010 at 14:46
  • 1
    @peroxide: In that case I'll post my last comment as an answer so that you can accept it, and we know this question is solved.
    – Jan Fabry
    Commented Oct 31, 2010 at 12:16

1 Answer 1


If something unexpected happens between query_posts() and get_post(), it is probably a plugin that hooks into the query and modifies it. Try disabling all plugins to see whether the problem disappears. Re-enable them one by one until you see the problem, that is the plugin that causes it.

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.