Support

Account

Home Forums Feature Requests Starting Rows – Repeater Field Reply To: Starting Rows – Repeater Field

  • This can be done with the acf/load_value filter https://www.advancedcustomfields.com/resources/acfload_value/.

    
    add_filter('acf/load_value/name='your-repeater-field-name', 'your_set_repeater_default_values_function_name', 10, 3);
    function your_set_repeater_default_values_function_name($value, $post_id, $field) {
      if ($value !== NULL) {
        // value will be exactly NULL if the field has never been updated
        // ie on a new post. If it is not null then you don't want to
        // overwrite what's there
        return $value;
      }
      // set new value
      $value = array(
        // a nested array for each row
        array(
          // and array item for each field
          // use field keys
          'field_1234567890abc' => 'default value',
          'field_01234567890ab' => 'default value',
          // etc...
        ),
        // another row
        array(
          // etc...
        ),
      );
    }