How do I use WP_query with multiple post IDs?

Please reference the Codex entry for post/page parameters for WP_Query().

The 'p' parameter takes a single post ID, as an integer.

To pass an array of posts, you need to use 'post__in':

$myarray = array(144, 246);

$args = array(
   'post_type' => 'ai1ec_event',
   'post__in'      => $myarray
);
// The Query
$the_query = new WP_Query( $args );

Leave a Comment