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.