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 want to query multiple posts with an array of IDs (note: I am querying a custom post type).

Here's what I have, which isn't working:

$myarray = array('144', '246');

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

Any tips on how to do this?

share|improve this question
up vote 10 down vote accepted

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 );
share|improve this answer

Your Answer

 
discard

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.