Viewing 2 replies - 16 through 17 (of 17 total)
  • Thread Starter andp

    (@andp)

    Repeatable Groups are great but i m facing some difficulties. using cmb2 i managed to create the desired custom meta fields for my user and my custom post type.

    using
    echo get_post_meta(get_the_ID(), ‘submitted_note’, true);
    i am able to display the value of my custom field on the front-end.

    i am straggling though to do this with me repeatable group values.

    in my db i have something like this
    a:1:{i:0;a:6:{s:25:”submitted_hotel_name”;s:14:”hotel one”;s:28:”submitted_hotel_acronym”;s:6:”depone”;s:28:”submitted_hotel_address”;s:4:”fdsd”;s:29:”submitted_hotel_postcode”;s:5:”sdfsd”;s:25:”submitted_hotel_city”;s:6:”sdfsdf”;s:28:”submitted_hotel_country”;s:6:”sdfsdf”;}}

    can u give me a quick hint of how to display a single value i.e submitted_hotel_postcode only.

    thank u

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    What you’re essentially seeing in that db value above is an array of repeatable groups. The group itself is an array, and it’s stored in an array with other group items, even if you only have 1 group at the moment.

    If you need to display them all, then you’re going to want to go with a foreach loop on the get_post_meta variable and in the loop, echo the different parts.

    If you’re needing to echo out parts of a specific group, it’s going to get more “interesting” because you need to find a way to isolate that group within the array of groups, and that’s not always easy. The immediate example that comes to my mind is a foreach loop still, and inside that, a bunch of conditional checking and echo’ing.

Viewing 2 replies - 16 through 17 (of 17 total)

The topic ‘Repeatable Groups’ is closed to new replies.