[wp-hackers] Get meta value with foreach

Jerry Johnson jmiloj at gmail.com
Wed Aug 18 01:47:42 UTC 2010

the 3rd parameter in your call, the false, tells the get_post_meta function
to return as many email metafields as it can find for that given post.

it returns these potential multiple values as an array.

if you only want to get one value, change the false to true.

if you want to handle the potential for multiple values, you will need to
treat $p as an array.


Jerry Milo Johnson

On Tue, Aug 17, 2010 at 9:42 PM, mailapera <mailapera at gmail.com> wrote:

> I get this function to get a custom meta value for each post called by the
> function, but for some reason the only output is the word "array" for each
> post instance.
> foreach ($my_posts as $post_id) {
>            $p = get_post_meta($post_id, 'email', false);
>            echo "$p";
>        }
> I don't get it
> _______________________________________________
> 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