Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
perfect! thank you, how could i miss that! –  mathiregister Feb 20 '13 at 12:09
    
@mathiregister u r welcome! :) –  Eugene Manuilov Feb 20 '13 at 12:11
add comment

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.