Support

Account

Home Forums Add-ons Repeater Field How do I programmatically delete all repeater rows? Reply To: How do I programmatically delete all repeater rows?

  • Hi John, Thanks for your code.
    I had trouble with this today, not all rows were being removed.
    I needed to remove them in reverse order:

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