我想你需要使用post__in
. 代码如下所示:
$args = array(
\'post__in\' => array( 1, 2 ),
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'image\',
\'no_found_rows\' => true,
\'posts_per_page\' => 2,
\'post_status\' => \'any\'
);
$query = new WP_Query($args);