Title: How do I sort posts by post__in ?
Last modified: August 20, 2016

---

# How do I sort posts by post__in ?

 *  [odyodyodys](https://wordpress.org/support/users/odyodyodys/)
 * (@odyodyodys)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/how-do-i-sort-posts-by-post_in/)
 * I want to retrieve a custom set of pages and sort them manually (in the post__in
   order)
 * my code is:
 *     ```
       query_posts(array(
       'post__in'=>array('16','20','22'),
       'post_type'=>'page',
       'order' => 'post__in'
       ));
   
       if ( have_posts() ) while ( have_posts() ) : the_post();
       	the_title();
        endwhile;
       ```
   
 * But the output is the titles ordered by date.
    I am using the `'order' => 'post__in'`
   as used in [this](http://www.thinkoomph.com/plugins-modules/wordpress-sort-query-by-post-in/)
   article.

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/how-do-i-sort-posts-by-post_in/#post-2258035)
 * as far as i can read, that article uses:
 * `'orderby' => 'post__in'`
 * it also assumes that you have activated that plugin.
 *  Thread Starter [odyodyodys](https://wordpress.org/support/users/odyodyodys/)
 * (@odyodyodys)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/how-do-i-sort-posts-by-post_in/#post-2258259)
 * Thanks alchymyth, I am using the plugin at the moment. My question was more about
   the wordpress core. If I can have that result without using a third party plugin.
   
   I want just to display posts in a specified order. I could do multiple loops 
   using WPquery but this is a funny solution 🙂
 *  [Big Bagel](https://wordpress.org/support/users/big-bagel/)
 * (@big-bagel)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/how-do-i-sort-posts-by-post_in/#post-2258263)
 * [This page](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters)
   has all the available options you can pass into ‘orderby’ without using any plugin.
   Perhaps one of them is what you’re looking for?

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

The topic ‘How do I sort posts by post__in ?’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [Big Bagel](https://wordpress.org/support/users/big-bagel/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/how-do-i-sort-posts-by-post_in/#post-2258263)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
