Home Forums Add-ons Repeater Field Delete repeater row programmatically


Delete repeater row programmatically

  • Does anyone know if it’s possible to delete a repeater row programmatically (i.e. not through the admin interface)?

    I’ve created a cron to loop a repeater field in my functions.php file – what I would like to do is delete the row if it is older than a certain date (the date is included in a sub_field within the row).

    Any help would be most appreciated.


  • Hi Mingis,

    Do you found the solution to delete a repeater row programmatically ?

    I’m looking to do the same…!


  • Hello,
    +1 for this question, i am looking for the solution too…

    if (have_rows('repeater_field', $post_id)) {
      $new_repeater = array();
      while (have_rows('repeater_field', $post_id)) {
        // perform check
        // will depend on what you're checking for
        if (get_sub_field('the_sub_field_to_check') == $some_value) {
          // the value is one you want to save
          $new_repeater[] = array(
            'sub_field_1_name' => get_sub_field('sub_field_1_name'),
            'sub_field_2_name' => get_sub_field('sub_field_2_name'),
            'sub_field_3_name' => get_sub_field('sub_field_3_name'),
        }  // end if check field
      } // end while have rows
      update_field('repeater_field', $new_repeater, $post_id);
    } // end if have rows
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Delete repeater row programmatically’ is closed to new replies.