I am using the Humanmade fork of a custom meta box class, they give the ability to set up groups of repeatable fields, as such I have a post saved with post_meta as follows ...

6 meta_id entries in the post_meta table with the same key "course-dates", each of these keys has sub keys and values as serialized data if you will, example as follows ...


How do I access these individual values or pull them all in and loop over them?

Thank you


Managed the below to get all combinations echoing out, still unsure how to go about accessing specific values ....

    $dates = get_post_custom ( $post->ID ); 
    $date = $dates['course-dates'];
    foreach ( $date as $d ) {
        $rpt = unserialize( $d );
        echo $rpt['course-dates-start'].' - '.$rpt['course-dates-end'];
        echo '<br/>';
  • Read this, set the last parameter for get_post_meta() to FALSE. – fuxia Apr 12 '13 at 18:54
  • no that doesn't work and has been tried, I have multiple meta_id with the same key – John Apr 12 '13 at 19:06
  • Don't use get_post_custom unless you absolutely need all the data it will send back to you, instead call get_post_meta with the appropriate values and iterate over the returned data(it will also unserialize the data for you if necessary - fyi you shouldn't be serializing it yourself, the functions provided by WP will do that as needed for you). – t31os Apr 12 '13 at 21:37
  • I have a very different setup with 6 meta_id entries all with the same key and within them a further 2 serialized key / values. These all belong to the same post as they were created using repeatable groups and fields. From what I can see Wordpress offers no way of accessing these and unserializing is the only route. I stand correcting but WP Query is not going to be able to handle this and I will need to look at another route. – John Apr 14 '13 at 0:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.