Hey everybody.
I have a group of select fields that I use to keep things organized for a client. I’m trying to figure out how/if there’s a way to get_field_objects without having to manually write out each statement?
Right now I loop over the acf group this way:
$cavereports = get_field('cave_reports')
if ($cavereports):
foreach ($cavereports as $cave){
echo "<li>". $cave['label'] . "-" . $cave['value'] . "</li>";
}
else:
echo "No data found.";
endif;
I’m ‘cheating’ the select system by having the value assigned label be the fields label, but i’d vastly perfer to just retrieve the actual field label itself. Is that possible?
Thank you!
You would need to loop over the group field using have_rows() rather than getting the group field, see the loop example for group fields. Doing this you can then use get_sub_field_object() in the loop to get each field object.