Home Forums General Issues Insert rows in repeater field which is in nested groups. Reply To: Insert rows in repeater field which is in nested groups.

  • You said that you are inserting a post. This means that the ACF fields have no values.

    update_row() will have no effect because there is no data to update, you would normally need to use add_row(). But you are dealing with nested fields so you would probably have to use add_sub_row(). But to add a sub row the row would have to exist first. In other words the fields public_information and expertise_in_numbers would have to exist before you try to add a row to numbers

    Also, because the values to not yet exist you would need to use field keys instead of field names.

    This would all get very complicated because of the nesting and then need to create the parent fields before you can add a row to the nested field. Instead I would use update_field() and I would build the array needed for the top level field.

    // a simple example
    $public_information = 'field_XXXXX'; // field key for public_information
    $expertise_in_numbers = 'field_YYYYY'; // field key for expertise_in_numbers
    $numbers = 'filed_ZZZZZ'; // field key for numbers
    $numbers_array = array();
    foreach ($number_values as $key => $number_value) {
      $numbers_array[] = array(
        // field key value pairs of repeater sub feilds
        'field_AAAAA' => $number_value,
        'field_BBBBB' => $number_suffix[$key],
        'field_CCCCC' => $number_text[$key]
    $value = array(
      $expertise_in_numbers  => array(
        $numbers => $numbers_array;
    update_field($public_information, $value, $post_id);