orderby:date not working

I have been searching for an answer and it seems like there are a lot of answers for the opposite issue. I am trying to sort by publish date, not by date modified, using this code:

query_posts($query_string . '&orderby=date&order=DESC&posts_per_page=-1');

But it is still sorting on date modified not publish date, can anyone help?

Read More

Thanks in advance!

Related posts

1 comment

  1. You should not have to specify orderby=date. That is the default. If you look at the query, you will see that the field used is post_date, which is the publication date and not the modification date– post_modified.

    You can prove this just by dumping $wp_query after your call to query_posts. Or try:

    $q = new WP_Query('posts_per_page=-1');
    var_dump($q->request);
    

    With no other parameters you get ORDER BY wp_posts.post_date DESC.

    If you are not getting that order there is already a filter that is altering default behavior. What is adding that filter I can’t guess.

    And yes, please don’t use query_posts.

Comments are closed.