Support

Account

Home Forums Add-ons Repeater Field Delete rows from repeater fields custom code Reply To: Delete rows from repeater fields custom code

  • Hi @rizwan157

    I believe you can do it like this:

    // set the object ID
    $post_id = 99;
    
    // this gets the repeater and all rows in an array
    $repeater = get_field('repeater_field', $post_id);
    
    // get the first row
    $first = array_shift($repeater);
    
    // update the repeater with the first row only
    update_field('repeater_field', $first, $post_id);

    Where ’99’ is the object (post/page) ID you want to update.

    I hope this helps 🙂