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.

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;
$args=array(
'category__in'=>array( $cat),
'order' => ASC,
'caller_get_posts' => 1,
'paged'=>$paged,
'orderby' => date,
);
query_posts($args);

How can I sort properly?

share|improve this question
    
im using wordpress with buddypress –  peroxide Oct 27 '10 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 Oct 27 '10 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 Oct 27 '10 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 Oct 28 '10 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 Oct 31 '10 at 12:16
show 6 more comments

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

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

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