I’m trying to query posts based on a number of ID’s that are contained in an array.
My array (called $my_array) looks like this:
Array
(
[0] => 108
[1] => 129
[2] => 145
)
And my Query looks like this:
<?php query_posts(array('post__in' => $my_array)); ?>
However this just returns one post, the post has the ID of the first item in the array (108).
Do I have my syntax wrong?
or
You always have to set the
post_type
with thepost__in
argument. So your line should look like the following:That will query the posts with the IDs you have in the array.
Daniel,
I am posting an answer, although you probably found it. I don’t have reputation yet to post comments, query_posts supports all the arguments from WP_Query including ordering you can add ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ to the query_posts call