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.

link|improve this question

71% accept rate
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
feedback

1 Answer

up vote 1 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);
);
foreach (get_posts($args) as $p) :
    //post!
endforeach;

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

link|improve this answer
Ah, thanks. I'll test this. Happy New Year :) – Steven Dec 31 '11 at 12:21
feedback

Your Answer

 
or
required, but never shown

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