Home › Forums › Add-ons › Repeater Field › Delete repeater`s sub_field after expired date › Reply To: Delete repeater`s sub_field after expired date
To do this you need to use a CRON that:
Notes, you must delete the rows in revers order and you cannot use an have_rows loop to loop over the rows. The reason is this, lets say that you delete row 2, row 3 then becomes row 2 and the next iteration of the loop will look at row 3, which was row 4 before the deletion and the loop skips what was row 3 because it is now row 2.
$repeater = get_field('repeater_name');
// $repeater is an array of rows
$count = count($repeater);
for ($row=$count; $row>0; $row--) {
if (//DATE EXPIRED//) {
delete_row('repeater_name', $row);
}
}
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.