I have a function that remove the value of repeater field when this value is old date, but not deleting the row, this still show but empty. How I can remove the rows when the value is null or empty?
This is the estructure of my custom fields:
r1 (repeater)
- t1 (text)
- t2 (text)
- r2 (repeater)
-- d1 (date)
This is my function:
$fields = get_fields();
foreach($fields as $key_1=>$value_1) {
$parent_i = 1;
foreach($value_1 as $key_2=>$value_2) {
foreach($value_2 as $key_3=>$value_3) {
$child_i = 1;
if ($key_3 == 'movies') {
foreach($value_3 as $key_4=>$value_4) {
foreach($value_4 as $key_5=>$value_5) {
if( $value_5 < $time_now) {
delete_sub_field( array('cinema', $parent_i, 'movies', $child_i, 'date') );
} elseif( $value_5 > $time_now) {
update_sub_field( array('cinema', $parent_i, 'movies', $child_i, 'date'), $value_5 );
}
$child_i++;
}
}
}
}
$parent_i++;
}
}