Home › Forums › Add-ons › Repeater Field › Display future events
Hi,
I am wanting to display only future events (horse races in this case). I am using the repeater field with a subfield. Any ideas how I would edit this code to only display events that are on today and in the future?
Thanks for taking the time to read this.
<?php if( have_rows('current_hr_entries') ): ?>
<div class="table-1">
<?php
$repeater = get_field('current_hr_entries');
foreach( $repeater as $key => $row ) :
$column_id[ $key ] = $row['date'];
endforeach;
array_multisort( $column_id, SORT_ASC, $repeater );
$currMonth = "start";
foreach( $repeater as $row ) :
$date = DateTime::createFromFormat('Ymd', $row['date']);
if ($currMonth != $date->format('F'))
:
echo '<table width="100%">';
echo '<tbody>';
echo '<tr class="month-heading"><td colspan="5">' . $date->format('F') . '</td></tr>';
$currMonth = $date->format('F');
endif;
?>
<tr>
<td><a rel="prettyPhoto" href="<?php echo $row['link_to_race']; ?>?iframe=true&width=100%25&height=100%25"><?php echo $row['horse_name'] ?></a></td>
<td><a rel="prettyPhoto" href="<?php echo $row['link_to_race']; ?>?iframe=true&width=100%25&height=100%25"><?php echo $date->format('D jS') ?></a></td>
<td><a rel="prettyPhoto" href="<?php echo $row['link_to_race']; ?>?iframe=true&width=100%25&height=100%25"><?php echo $row['time'] ?></a></td>
<td><a target="_blank" href="<?php echo $row['racecourselink']; ?>"><?php echo $row['race_course'] ?></a></td>
<td><a rel="prettyPhoto" href="<?php echo $row['link_to_race']; ?>?iframe=true&width=100%25&height=100%25"><?php echo $row['race_name'] ?></a></td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
</div>
<?php endif; ?>
Section 4 of this How To give an example of querying posts by a repeater sub field. http://www.advancedcustomfields.com/resources/query-posts-custom-fields/
Hi John,
Sorry for late reply. Thanks for the info. Much appreciated.
Regards,
Rob.
The topic ‘Display future events’ is closed to new replies.
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.