Home › Forums › Add-ons › Repeater Field › Delete repeater`s sub_field after expired date › Reply To: Delete repeater`s sub_field after expired date
Got it. But now it deletes all the rows, i think i write bad IF function or delete_row
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
);
$listings = new WP_Query( $args );
$count = 0;
$today = date( 'Y-m-d' );
global $product;
// The Loop
if ( $listings->have_posts() ) {
echo '<ul>';
while ( $listings->have_posts() ) {
$listings->the_post();
$count = 0;
$repeater = get_field('pasirinkti_datas',$listings->ID);
if (is_array($repeater)) {
$count = count($repeater);
}
for ($row=$count; $row>0; $row--) {
if (get_sub_field('keliones_datos',$listings->ID) <= $today ) {
delete_row('pasirinkti_datas', $row,$listings->ID);
}
}
echo '<li>' . get_the_title() .$count . '</li>';
}
echo '</ul>';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
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.