Support

Account

Home Forums Add-ons Repeater Field Deleting rows on options page programmatically doesn't seem to work Reply To: Deleting rows on options page programmatically doesn't seem to work

  • My guess is the way you are attempting to delete the rows. Let’s say that your repeater has 6 rows. After deleting the first 3 it only has 3 rows and calling have_rows() the 4th time returns false because there is no longer a 4th row. However, this is just a guess.

    if this is the case then I would amend the code I posted in the other topic https://support.advancedcustomfields.com/forums/topic/how-do-i-programmatically-delete-all-repeater-rows/ to this to delete the rows starting at the end instead of the beginning.

    
    $images = get_field('images');
    if (!empty($images)) {
      $count = count($images);
      for ($index=$count; $index>0; $index--) {
        delete_row('images', $index);
      }
    }