[wp-hackers] Get meta value with foreach
mailapera
mailapera at gmail.com
Wed Aug 18 01:54:27 UTC 2010
I can't believe it! I am an ass! I have been struggling over this for hours
and I was just overlooking that bit.
Thank you both Jerry and Paul
On Wed, Aug 18, 2010 at 3:47 AM, Jerry Johnson <jmiloj at gmail.com> wrote:
> 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.
>
> http://codex.wordpress.org/Function_Reference/get_post_meta
>
> hth
> 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
> >
> _______________________________________________
> 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