Title: query_posts: retrieve only certain posts
Last modified: August 20, 2016

---

# query_posts: retrieve only certain posts

 *  Resolved [fenomenon_79](https://wordpress.org/support/users/fenomenon_79/)
 * (@fenomenon_79)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/query_posts-retrieve-only-certain-posts/)
 * Hi,
    I couldn’t find how to use query posts to retrieve certain posts by ID.
 * This only show last post which isn’t ID 1 nor 2 nor 3:
    `query_posts('p=1,2,3');`
 * This retrieve last 3 posts, which aren’t 1 nor 2 nor 3:
    `query_posts('p=(1,2,3)');`
 * I appreciate any kind of help.
    thanks.

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/query_posts-retrieve-only-certain-posts/#post-2468100)
 * [http://codex.wordpress.org/Function_Reference/query_posts](http://codex.wordpress.org/Function_Reference/query_posts)
   
   [http://codex.wordpress.org/Function_Reference/WP_Query](http://codex.wordpress.org/Function_Reference/WP_Query)(
   you can use the same parameters with query_posts).
 *  Thread Starter [fenomenon_79](https://wordpress.org/support/users/fenomenon_79/)
 * (@fenomenon_79)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/query_posts-retrieve-only-certain-posts/#post-2468415)
 * Thanks esmi.
 * It worked by _merging_ that 2 functions:
 * `query_posts(array( 'post__in' => array(1,2,3) ))`
 * Cheers.

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

The topic ‘query_posts: retrieve only certain posts’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [fenomenon_79](https://wordpress.org/support/users/fenomenon_79/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/query_posts-retrieve-only-certain-posts/#post-2468415)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
