
update_field('field_5a846b336d34f', $finalArray , $post_id);
$finalArray[]=array(
"field_5a846b336d351"=>"NAME",
"field_5a846b336d353" => "EMAIL",
"field_5a846b336d352" => "TITLE",
"field_5a846b336d354" => "PHONE"
);
So this is the standard way to add rows to a repeater in ACF. It works great on a repeater that is not nested or in a Flexible content block (ACF). The field id in the update_field is the repeaters, who is inside of a Flexible Content Block. This seems to be giving me fits due to it’s location. I have looked at help docs everywhere. If I am calling the repeater by its field ID, why should it matter where it is located in the layouts in ACF? One more note: This repeater is a CLONE but each time I use it as a clone on the site it has it’s own field ID so that shouldn’t give me grief? I am trying to add multiple rows to it at once. Works great on a repeater NOT buried in ACF objects.
I don’t know if this will help or not, but it will give you an idea of where the repeater is located in the ACF page build. Below is what I use to get the output:
while ( have_rows(‘page_builder’,$post_id) ) : the_row();
if( get_row_layout($post_id) == ‘staff_directory’ ): // Staff Directory
if( have_rows(‘directory_type’,$post_id) ):
while ( have_rows(‘directory_type’,$post_id) ) : the_row();
if( get_row_layout($post_id) == ‘directory_table’ ):
if( have_rows(‘staff_member’,$post_id) ):
while ( have_rows(‘staff_member’,$post_id) ) : the_row();
/// THIS IS WHERE I WOULD CALL THE RESULTS OF THE REPEATING INFORMATION ///
endwhile;
endif;
endif;
endwhile;
endif;
endif;
endwhile;
In order to use update_field() you would need to include all of the rows of the flex field as well as all of the rows of the repeater.
$flex_field = array(
array(
// each row of the flex field
'field_XXXXXXX' => array(
// nested repeater field
array (
// each row of the repeater
'field_YYYYY' => 'value'
)
)
)
);
This is not the way to add a row to a repeater nested in a flex field.
See add_sub_field_row() and/or update_sub_field().