Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 ...

a:2:{s:18:"course-dates-start";s:10:"11/25/2013";s:16:"course-dates-end";s:10:"12/20/2013";}

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

Thank you

*EDIT***

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

            <?php 
            $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/>';
            }
            ?>
share|improve this question
    
Read this, set the last parameter for get_post_meta() to FALSE. –  toscho 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.