WP_Query: query posts by ids from array?

You have to use post__in (double underscore) argument, instead of post_in:

echo print_r($rel); // Array ( [0] => 63 [1] => 87 )

$args = array(
    'post_type' => array( 'post' ),
    'orderby' => 'ASC',
    'post__in' => $rel
);

$loop = new WP_Query( $args );

If you are unsure why an argument is not working, copy it’s key name from manual and past it into you snippet.

Leave a Comment