Support

Account

Home Forums Add-ons Repeater Field Fill up repeater fields with category Reply To: Fill up repeater fields with category

  • You need to do this on the load value hook for the repeater

    example:

    
    add_filter('acf/load_value/name=your-repeater-field-here', 'preload_repeater', 20, 3);
    function preload_repeater($value, $post_id, $field) {
      if (!empty($value)) {
        // this repeater already has a value do not change it
        return $value
      }
      // code here to populate repeater
    
      // this is an example of what ACF is expecting for the value
      // the repeater value is an array
      $value= array(
        // each row is a nested array
        array(
          // each nested row array is made up of "field key" => "value pairs"
          'field_012345' => 'value for this sub field',
          'field_123456' => 'value for 2nd sub field',
          // etc....
        ),
        // second row
        array(
          // etc...
        ),
        // etc...
      );
    
      return $value;
    
    }