• Recently (https://core.trac.www.ads-software.com/changeset/19908), the get_post_meta function was changed to work with just a post ID as a parameter, so that it can be called like this:

    $data = get_post_meta($post_id)

    However, I noticed that it returns every value as an array (so more like get_post_custom). I tried the following:

    $event_meta = get_post_meta( $e->ID , '', true);

    I was expecting that it would return all of my custom fields as single strings, since I’m passing a $single parameter.

    It doesn’t quite work that way, though – it’s still returning each field as an array.

    Looking at the core code, I can understand why, but I’m wondering if this feature would be useful to others as it is to me.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The $single parm only works if you pass a $key name, yielding a single result. If you get an array of results, you simply step through the array to do whatever. If one got a list of results instead of an array, one would probably have to explode it, resulting in an array. So I don’t see much point, but I will allow that someone may have a use for such a list as is.

Viewing 1 replies (of 1 total)
  • The topic ‘How should this work / get_post_meta’ is closed to new replies.