Title: query_posts() won&#039;t sort properly
Last modified: August 22, 2016

---

# query_posts() won't sort properly

 *  [LinusOnTheLine](https://wordpress.org/support/users/linusontheline/)
 * (@linusontheline)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/query_posts-wont-sort-properly/)
 * Trying to modify a theme with a child theme. There’s something fishy with a query_posts().
   I have these arguments which are defaults:
 *     ```
       Array
       (
           [post_type] => post
           [post_status] => publish
           [category_name] =>
           [posts_per_page] => 4
           [offset] => 0
           [order] => DESC
       )
       ```
   
 * i’ve tried with “orderby” => ‘date’ as well. If i change the post_type to ‘products’,
   for examle, i get the products but not in a date order. the sorting function 
   just does not work no matter what i do.
 * I’ve tried this as well:
 *     ```
       $blog_posts = query_posts($args);
       foreach($blog_posts as $bp)
       {
           echo '<pre>';
           print_r($bp->post_date);
           echo '</pre>';
       }
       ```
   
 * and tried all different kind of variations – the sorting does just not work. 
   Going nuts here. Everything excetp sorting is working. Any tips of plugins which
   messes with my query, or known bugs/problems regarding this?
    Or, in this case,
   something like
 *     ```
       query_posts($args);
       if(have_posts())
       {
           while(have_posts())
           {
               //Reverse this loop?!
           }
       }
       ```
   
 * would work as well.

The topic ‘query_posts() won't sort properly’ is closed to new replies.

## Tags

 * [order](https://wordpress.org/support/topic-tag/order/)
 * [orderby](https://wordpress.org/support/topic-tag/orderby/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [sorting](https://wordpress.org/support/topic-tag/sorting/)

 * 0 replies
 * 1 participant
 * Last reply from: [LinusOnTheLine](https://wordpress.org/support/users/linusontheline/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/query_posts-wont-sort-properly/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
