Leave a Reply

1 comment

  1. Aha! I think I found your answer. Two facts:

    An array will be serialized into a string.

    If set to true then the function will return a single result, as a string. If false, or not set, then the function returns an array of the custom fields. This is not intuitive. For example, if you fetch a serialized array with this method you want $single to be true to actually get an unserialized array back. If you pass in false, or leave it out, you will have an array of one, and the value at index 0 will be the serialized string. (emphasis added)

    Therefore, this [untested] snippet should get you your food array as an array rather than a serialized string.

    $food_field = get_post_meta( $post->ID, 'food', true );