I was looking at the update_field() information page and I was wondering if this is supported with the flexible content field? I noticed that there are no field keys showing for sub-fields.
I would like like to build my own script for inserting data into posts using this field. Can this be done?
Hi @mageguild,
Thanks for the post.
Yes this can be achieved, you can also opt to pass the field names instead.
For flexible content field and the Repeater field, I would suggest you make use of the update_sub_field() instead.
Please have a look at the following page for more info on this: https://www.advancedcustomfields.com/resources/update_sub_field/
@acf-support Could you post an example of using update_sub_field() to add data to a field inside a flexible content layout?
I can’t see any example for other than a repeater field in the doc page and tried using the Flexible Content field name and field and value but no luck yet.
update_sub_field( array( 'my_fc_layout_field_name', 1, 'document' ), 623 );
In the screenshot is reflected my Flexible Content field and Layout with field (document) I want to add the media ID value 623.
I also stuck on this problem. I’ve imported some posts, but one group ist not accessible via get_field(), although all values appear in the backend. So I guess I need to update these group values to register them correctly in the database. But how to do it? They are placed inside flexible content fields themselves, so the meta_key in the database look like
content_section_3_button_text
…..
…..
…..
content_section_9_button_text
Which means, ‘content_section’ is the flexible content field with different sections inside, and these sections have got a group called ‘button’ with a child field ‘text’ (for the button text) inside.
I also tried to access them with the field_keys, but no success yet. Any ideas? Thanks a lot!