I use the https://github.com/humanmade/Custom-Meta-Boxes/ to make this custom repeatable custom fields to wordpress. The given arrays are like this
Array
(
[0] => Array
(
[photoset-caption] => Array
(
[cmb-field-0] => Caption1
[cmb-field-1] => Caption2
[cmb-field-2] => Caption3
[cmb-field-3] => Caption4
)
[photoset-image] => Array
(
[cmb-field-0] => 17
[cmb-field-1] => 16
[cmb-field-2] => 15
[cmb-field-3] => 14
)
)
[1] => Array
(
[photoset-caption] => Array
(
[cmb-field-0] => Caption1
[cmb-field-1] => Caption2
[cmb-field-2] => Caption3
[cmb-field-3] => Caption4
)
[photoset-image] => Array
(
[cmb-field-0] => 17
[cmb-field-1] => 16
[cmb-field-2] => 15
[cmb-field-3] => 14
)
)
)
The loop it try to make is this.
// get the custom fields for this post
$photoset = get_post_meta($post->ID, 'photoset_group_fields', false );
echo '<div class="photoset">';
echo '<div class="photoset-row">';
foreach($photoset as $photosetloop){
echo '<figure class="photoset-item">';
echo '<div>' . wp_get_attachment_image($photosetloop['photoset-image'], 'large' ) . '</div>';
echo '<figcaption>' . $photosetloop['photoset-caption'] .'</figcaption>';
echo '</figure>';
}
echo '</div>';
echo '</div>';
So the loop haves .photoset-item and inside it have image and caption. My question how to I foreach it, thanks.
I did update for the array, i have group that I loop.