Home › Forums › Add-ons › Repeater Field › repeater dates arranged by months title › Reply To: repeater dates arranged by months title
Thank you James
I have done the repeater sort. it sorts by date. and also hide the past dates…
but i need to separate the dates into months and hide past months –
this is the problem i couldn’t figure.
the code i used so far.
<?php
// get repeater field data
$repeater = get_field('vacation_repeater1');
// vars
$order = array();
if( $repeater ):
// populate order
foreach( $repeater as $i => $row ) {
$order[ $i ] = $row['start_date'];
}
array_multisort( $order, SORT_ASC, $repeater );
?>
<?php foreach( $repeater as $i => $row ): ?>
<?php
$end_date = get_sub_field('end_date');
$today = date('Ymd');
$get_startdate = $row['start_date'];
$start_date = (strtotime($get_startdate));
//use $get_startdate to order, and $start_date_pretty to output your date
$start_date_pretty = date_i18n( 'l, F j, Y', $start_date );
?>
<?php if($today <= $get_startdate ) { ?>
<ul>
<li class="flight_date_time">
<?php echo $start_date_pretty; ?>
</li>
<li class="flight_date_time">
<?php echo $row['end_date']; ?>
</li>
</ul>
<div class="clear"></div>
<?php } ?>
<?php endforeach; ?>
<?php endif; ?>
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.