[wp-hackers] WP_Query and multiple pages

Will Anderson wp-hackers at itsananderson.com
Mon Aug 3 19:40:19 UTC 2009


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
> page.
>

I forgot to mention, the array that's returned is a little funky because
there can be multiple custom field values. Check out the Codex page for more
info.

http://codex.wordpress.org/Function_Reference/get_post_custom

It's basically going to be of the form:

Array(
'key1' => Array(
                      0 => 'value1',
                      1 => 'value2'
                      ),
'key2' => Array(
                      0 => 'value1'
                      )
)

-- 
Will Anderson
http://www.itsananderson.com/


More information about the wp-hackers mailing list