Title: Display posts using post IDs in an array?
Last modified: August 20, 2016

---

# Display posts using post IDs in an array?

 *  Resolved [debsch](https://wordpress.org/support/users/debsch/)
 * (@debsch)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/display-posts-using-post-ids-in-an-array/)
 * I have sorted an array of post IDs based on multiple custom fields/values, for
   example…
    `Array ( [0] => 804 [1] => 771 [3] => 765 [4] => 784 [5] => 807 )`
 * but now I have no idea how to display these posts IN THIS ORDER using this array.
 * Help?

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

 *  Thread Starter [debsch](https://wordpress.org/support/users/debsch/)
 * (@debsch)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/display-posts-using-post-ids-in-an-array/#post-3523098)
 * Solved using `post__in`
 *     ```
       $myarray = array_unique($result, SORT_NUMERIC);
       print_r($myarray);
   
       query_posts( array(
          'orderby' => 'ID',
           'post__in' => $myarray,
                               ) );
       ```
   
 * EDIT….. that’s not working for me. Any ideas where I’m going wrong?
 *  Thread Starter [debsch](https://wordpress.org/support/users/debsch/)
 * (@debsch)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/display-posts-using-post-ids-in-an-array/#post-3523167)
 * AHHHHHHHHHHHHH HA…
 * `query_posts( array( 'post__in' => $myarray, 'orderby' => 'post__in' ) );`
 * (duh!)

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

The topic ‘Display posts using post IDs in an array?’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [IDs](https://wordpress.org/support/topic-tag/ids/)
 * [order](https://wordpress.org/support/topic-tag/order/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [debsch](https://wordpress.org/support/users/debsch/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/display-posts-using-post-ids-in-an-array/#post-3523167)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
