Hi!
I have a site builder created using the flexible content field. I would like to use this field in other groups. When I’m cloning this field in other groups it’s possible to pull out an array with e.g. get_fields(‘sections’) – unfortunately, as you can see, this array is nested, which makes it impossible to loop it with
while ( have_rows( ‘sections’ ) ): the_row();
//get_fields() output:
["sections"]=>
array(1) {
["sections"]=>
array(1) {
[0]=>
array(5) {
["acf_fc_layout"]=>
string(11) "my_section"
(...) // rest of fields
}
}
}
}
(...) // rest of fields
Is there any possibility to use this loop? I’d like to be able to extract the fields of individual sections using get_sub_field(), using the foreach loop on array will force me to rework all my sections. Is there a workaround? I would be grateful for any suggestions.
I think that you need to have another layer of while have_rows
looping inside using the name of the cloned field, rather than using get_fields()
which as you can see returns an array.
Each array inside of “sections” represents one row of the flex field.
Does the clone field have a parent field? What sttings are you using?
How are you adding the clone field?
What are the settings for the clone field?