[wp-hackers] WP_Query and multiple pages

John Kolbert admin at simply-basic.com
Mon Aug 3 19:32:53 UTC 2009


Try this:

<?php query_posts(array("post__in" => array(21,2,3,4), 'post_type' =>  
'page')); ?>


On Aug 3, 2009, at 2:20 PM, Ade Walker wrote:

> Hi all,
>
> If this has been down to death before - apologies in advance. I've  
> googled
> for hours and haven't come up with anything definitive on this.
>
> It seems that trying to query several page_id's when using
> query_posts/WP_Query doesn't work.
>
> query_posts('page_id=1,2,3,4') doesn't work, and neither does:
>
> query_posts('post__in' => array(5,12,2,14,7)) where the ID's are  
> actually
> page_id's.
>
> Is there any way to query a selection of specified Pages? In usual
> situations (to display page content) I can see that there isn't much  
> logic
> in being able to do this, but I want to access Custom field keys/ 
> values for
> a selection of Pages for a plugin.
>
> Other than an SQL query (which I'm using temporarily), any ideas  
> gratefully
> received! :-)
>
> Thanks.
>
> Ade.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list