[wp-hackers] WP_Query and multiple pages

Ade Walker photofantaisie at gmail.com
Mon Aug 3 20:05:53 UTC 2009


Will,

Thanks for the suggestion. Yes, I have the Page ID's available, and I
already thought of using get_post_custom. I think I'll dig a little deeper
into this and see if this will work for me. Apart from the post title, which
I can get with get_the_title(), I only need custom field data for these
Pages, therefore avoiding the overhead of a post object would be ideal.

2009/8/3 Will Anderson <wp-hackers at itsananderson.com>

> 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/
> _______________________________________________
> 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