WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a string with post ID's: 43,23,65.
I was hoping I could use get_posts() and use the string with ID's as an argument.

But I can't find any functions for retrieving multiple posts by ID.

Do I really have to do a WP_query?

I've also seen someone mention using tag_in - but I can't find any documentation on this.

share|improve this question
have you tried to use the 'include' argument of get_posts() codex.wordpress.org/Template_Tags/get_posts ? – Michael Dec 31 '11 at 11:56
up vote 12 down vote accepted

You can use get_posts() as it takes the same arguments as WP_Query.

To pass it the IDs, use 'post__in' => array(43,23,65) (only takes arrays).

Something like:

$args = array(
    'post__in' => array(43,23,65)

$posts = get_posts($args);

foreach ($posts as $p) :

I'd also set the post_type and posts_per_page just for good measure.

share|improve this answer
Ah, thanks. I'll test this. Happy New Year :) – Steven Dec 31 '11 at 12:21
This doesn't work. – Dissident Rage Aug 5 '15 at 19:22
No? Are you passing it as an array? Using two underscores (post__in vs post_in)? Passing a post_type? – CookiesForDevo Aug 6 '15 at 1:10

in case you cant get the above to work make sure you add post_type eg

$args = array(
                    'post_type' => 'pt_case_study',
                    'post__in' => array(2417, 2112, 784)
                $posts = get_posts($args);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.