ACF: How to programmatically Update Flexible Content Field?
I want to be able to create sub fields inside a flexible content field.
My setting is this one:
menu_item_field is a flexible content field that contains:
1.1 menu_item_parent (text)
1.2 menu_item_child (repeater field)
---1.2.1 menu_item_child_title (text)
---1.2.2 menu_item_child_text (text)
---1.2.3 menu_item_child_img (repeater field)
------1.2.3.1 menu_item_child_img_item (img)
This is the structure that results of the above setting:
Group One
Item 1 title
Item 1 description
Item 1 img 1
Item 1 img 2
Item 2 title
Item 2 description
Item 1 img 1
Item 1 img 2
So far I’ve been able to insert only the Group field and I wanted to know if it’s possible to do more complex stuff.
I did it using:
add_row(
'menu_item_field', [
'acf_fc_layout' => 'menu_item',
'menu_item_parent' => 'Group One',
], $postID)
The above code returned only the main group titles:
Group One
I know there’s update_sub_row()
but I haven’t been able to successfully use it.
My main goal is to be able to edit or create new fields using a custom UI in the frontend through AJAX.
I prefer this instead of acf_form().
So, my question, is it possible to achieve what I need and what would be the proper function with the above settings.
Thanks.
Leave an answer
You must login or register to add a new answer .