I did quite a bit of research but can’t figure why this wouldn’t work for me?

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 );

I don’t get any posts returned? Any ideas how to only get the posts with the ids in the array?

1
1

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 Reply

Your email address will not be published. Required fields are marked *