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);
}
}
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.