Home › Forums › Add-ons › Repeater Field › Calendar by month with date repeater › Reply To: Calendar by month with date repeater
After that, you can sort the data by using the array_multisort() function. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/how-to-sorting-a-repeater-field/. Here’s an example how to do it:
$rows = ''; // The variable that holds the repeater result
// vars
$order = array();
// populate order
foreach( $rows as $i => $row ) {
$order[ $i ] = $row['meta_value'];
}
// multisort
array_multisort( $order, SORT_ASC, $rows );
$current_month = null;
foreach( $rows as $row){
$date = DateTime::createFromFormat('Ymd', $row['meta_value']);
$month = $date->format('F');
if( $current_month != $month ){
echo $month . "\r\n";
$current_month = $month;
}
echo $row['meta_value'] . "\r\n";
}
You can also get the post object by using the get_post() function like this:
echo $row['meta_value'] . "\r\n";
$thepost = get_post($row['post_id']);
print_r($thepost);
I hope this helps 🙂
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.