I am scraping some albums from a third-party site and then inserting them into WordPress. I have numerous fields using Advanced Custom Fields Pro and the Flexible Content Layout functionality. My issue is I cannot understand how I can insert multiple items in a repeater which is in a Flexible Content Layout.
My structure is as follows:
page_sections (Flexible Content)
I came across the documentation http://www.advancedcustomfields.com/resources/update_field/ for the
update_field() method which has some examples for updating/inserting data. One of those examples is for inserting a Flexible content row.
While I understand how it would work for simple sub-fields like text, how would I go about adding in multiple items which are in the repeater that sits within my Flexible content row?
You’ll need to combine the one for the flexible content row with the one for the repeater row just above it.
$field_key = "flexible_field";
$value = get_field($field_key);
$value = array(
"sub_field_1" => "Foo1",
"sub_field_2" => "Bar1",
"repeater_field" => array(
'repeater_sub_1' => 'value',
'repeater_sub_2' => 'value'
"acf_fc_layout" => "layout_1_name"),
update_field( $field_key, $value, $post_id );