Home › Forums › Add-ons › Repeater Field › Repeater for a list of date › Reply To: Repeater for a list of date
Hi @ikazi
Something like the code below should do the trick…
In it, I loop through the repeater, and add only non-expired dates to an array..
.. then I sort it… then… you can loop through the result set. Give it a try and let me know 🙂
$repeater = get_field('list_of_date');
foreach( $repeater as $key => $row ) {
if ( strtotime( $row['date_end'] ) > strtotime( date() ) ) { // not expired, add to array
$column_id[ $key ] = $row['date_start'];
}
}
array_multisort( $column_id, SORT_ASC, $repeater ); // sort the array
foreach( $repeater as $row ) {
// loop through the array
}
Resource: https://support.advancedcustomfields.com/forums/topic/repeater-sorted-by-date/
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.