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 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.