Using ACF Pro v5.3.7. I have a situation where I need to be able to retrieve the names (preferably the field name) of all the child fields of a layout without having to go through the “loop”. Ideally, something that returns an array with each child field name. I’ve gone through the documentation and get_row() is the closest match I can find, but that requires me to be going through the loop.
I’ve also combed through the database and see how you’re storing the list of layouts in a flexible content space, but have been unable to find anything that lists the child fields of that layout. I also found the parent_layout value in a specific field, but I really need to go from the top down (parent –> child –> grandchild –> etc) instead of the bottom-up.
Is there a function I’m just overlooking? Or can you point me in the direction of either the database or the code where I can retrieve this information?
There are some internal functions.
$fields = acf_get_fields($group_key);
will get all the fields in a field group, you can loop through the entire group.
$field = acf_get_field($field_key);
will get a specific field, you can then look in $field['layouts'][$layout_key]['sub_fields'];
I don’t think that there is a function for getting a field’s sub fields.