[wp-hackers] WP_Query and multiple pages
wp-hackers at itsananderson.com
Mon Aug 3 19:34:57 UTC 2009
On Mon, Aug 3, 2009 at 3:20 PM, Ade Walker <photofantaisie at gmail.com> 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
> 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! :-)
If you've already got a list of page ID's for which you'd like to get the
post meta, why not just loop through the ID's and call get_post_custom on
them. It will return a key/value associative array of the meta fields. This
should also have a lot less overhead than generating a post object for each
More information about the wp-hackers