I was able to find a solution that worked for me. I'll post it here incase someone else comes across this problem.
So, the trick was creating an array from the get_field_object function to get all subfield names and then using that array when going through the parent field to gain access to both value and label.
$parent_field = get_field_object('your-parent-field-name');
$fields = array();
if (count($parent_field['sub_fields'])) {
foreach ($parent_field['sub_fields'] as $field) {
$fields[] = $field['name'];
}
}
if( have_rows($parent_field) ):
while ( have_rows($parent_field) ) : the_row();
foreach ($fields as $sub_field) {
$field = get_sub_field_object($sub_field);
echo '<span>' . $field['label'] . ':' . $field['value'] . '</span>';
}
I'm not sure if this is the most eloquent solution or not. But it works for now.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…