Support

Account

Home Forums ACF PRO Updating Repeater Fields: update_field() vs. add_row() Reply To: Updating Repeater Fields: update_field() vs. add_row()

  • When you use update_field() you would need to include all of the existing values along with the new values. This means that you need to first get all the existing values and then add a new row to it and then use update_field().

    When using add_row(), the value you’re using is incorrect. For update_field() it should be the nested array that you have, each row being nested in the repeater. However, when updating a single row this array should not be nested.

    
    
      $value = 
          array(
              'field_5c4b34917ab9b'	=> implode(', ', $regions), // text area (sub field)
              'field_5c4b34c87ab9c'	=> implode(', ', $sectors), // text area (sub field)
              'field_5c4b34d17ab9d' => date('Y-m-d H:i:s', time()) // text (sub field)
      );
      add_row($field_key, $value, $pressReleaseID);