Title: Using WP_Query without sorting
Last modified: August 19, 2016

---

# Using WP_Query without sorting

 *  [Peter Monte](https://wordpress.org/support/users/stevestall/)
 * (@stevestall)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/using-wp_query-without-sorting/)
 * Hello,
 * I’m using WP_Query to retrieve several posts. I know witch posts I want and in
   witch order so I created an array with all the required IDs. Unfortunately the
   result of WP_Query does not reflect the order of my array with the IDs. Tried
   to use the orderby=none but no result:
 *     ```
       $ids = array (60, 23, 78, 46, 105, 130)
       $args = array (
       	'posts_per_page' => count($ids),
       	'post__in' => $ids,
       	'orderby' => 'none'
       );
   
       $query = new WP_Query ( $args );
   
       if ( $query->have_posts() ) : while...[bla bla bla]
       ```
   
 * The result is always in ID descending order.
 * Can anyone help me?
 * Thanks
    PM

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/using-wp_query-without-sorting/#post-2074609)
 * you could try and use a ‘foreach’ loop with you `$ids` array, and use `get_post()`
   or so.
 * [http://codex.wordpress.org/Function_Reference/get_post](http://codex.wordpress.org/Function_Reference/get_post)
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/using-wp_query-without-sorting/#post-2074610)
 * If you set `orderby` to none, doesn’t that mean you’ll get the posts in the order
   they’re retrieved from the database – which will be in id order descending, IIRC?
   So you may be getting exactly what you asked for.
 * I’m not sure that you can specific the order of the post via the `post__in` array.
 *  Thread Starter [Peter Monte](https://wordpress.org/support/users/stevestall/)
 * (@stevestall)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/using-wp_query-without-sorting/#post-2074686)
 * [@alchymyth](https://wordpress.org/support/users/alchymyth/)
 * Hi alchymyth, thanks for the reply.
 * that could work, though forces the server to compute more then necessary.
    How
   could I use your solution and still use the wordpress typical loop:
 *     ```
       if ($query->have_posts()) :while ($query->have_posts()) : $query->the_post();
       ```
   
 * Thanks
 * //——————————————————————-
 * [@esmi](https://wordpress.org/support/users/esmi/)
 * Hi esmi, thanks for the reply.
 * One way or the other I always get a sort. If I don’t define orderby=none wordpress
   code will use ID has default.
 * Thanks
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/using-wp_query-without-sorting/#post-2074689)
 * Why not add custom fields to your selected posts? If you were a little imaginative
   with the meta-value, you could then use `meta_value_num` to order your posts.
 *  Thread Starter [Peter Monte](https://wordpress.org/support/users/stevestall/)
 * (@stevestall)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/using-wp_query-without-sorting/#post-2074748)
 * [@esmi](https://wordpress.org/support/users/esmi/)
 * Actually posts are edited with magic-fields plugin.
 * I have a single post with several relationship combo-box that order 10 posts.
   A combo for each post. Combos point to all website posts id.
 * In PHP I get all posts ids listed correctly but when I make the final call to
   retrieve all identified posts orders come incorrect

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Using WP_Query without sorting’ is closed to new replies.

## Tags

 * [descending](https://wordpress.org/support/topic-tag/descending/)
 * [none](https://wordpress.org/support/topic-tag/none/)
 * [orderby](https://wordpress.org/support/topic-tag/orderby/)
 * [post__in](https://wordpress.org/support/topic-tag/post__in/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [Peter Monte](https://wordpress.org/support/users/stevestall/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/using-wp_query-without-sorting/#post-2074748)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
