Home › Forums › Add-ons › Repeater Field › future dates table in single.php › Reply To: future dates table in single.php
Dear John,
thank you for your reply.
Do you mean it like this? There must be a mistake somewhere…
maybe with the { ?
Sorry I´m an absolute newbie in php…
<?php
while ( have_rows('t_block') ) : the_row();
$now = strtotime(date('Y-m-d', time()));
// I am assuming that your date is stored as 'Y-m-d'
// see strtotime php doc form more information
$end_time - strtotime(get_sub_field('ende'));
if ($now > $end_time) {
// not in the future, go to the next row
continue;
}
// check if the repeater field has rows of data
if( have_rows('t_block') ):
echo '<h2>' . 'Reisetermine' . '</h2>';
echo "<table>";
echo '<tr> <th>'.''.'</th>';
echo '<th>' . '' . '</th>';
echo '<th>' . Anreise . '</th>';
echo '<th>'.''.'</th>';
echo '<th>' . Abreise . '</th>';
echo '<th>' . 'Preis p.P. <br> im DZ' . '</th>';
echo '<th>' . '' . '</th>';
echo '<th>' . '' . '</th>';
echo '<th>' . '' . '</th>';
echo '<th>' . '' . '</th>';
echo '<th>' . '' . '</th></tr>';
// loop through the rows of data
while ( have_rows('t_block') ) : the_row();
$date_beginn = DateTime::createFromFormat('Ymd', get_sub_field('beginn'));
$date_ende= DateTime::createFromFormat('Ymd', get_sub_field('ende'));
$preis= get_sub_field('preis');
$preis_ez= get_sub_field('ez_preis');
$buchbar= get_sub_field('buchbar');
$sprache= get_sub_field('sprache');
$anfrage= get_sub_field('anfrage');
$bemerkung= get_sub_field('bemerkung');
$garantiert= get_sub_field('gesichert');
// display a sub field value
echo '<tr><td>' . $garantiert . '</td>';
echo '<td>' . $buchbar . '</td>';
echo '<td>' . $date_beginn->format('d.m.Y') . '</td>';
echo '<td>' . '-' . '</td>';
echo '<td>' . $date_ende->format('d.m.Y') . '</td>';
echo '<td><strong>' . $preis . ' € </strong> </td>';
echo '<td>' . $preis_ez . ' </td>';
echo '<td>' . $sprache . '</td>';
echo '<td><strong>' . $anfrage . '</strong></td>';
echo '<td>' . $bemerkung . '</td> </tr>';
endwhile;
echo "</table>";
else :
echo get_post_meta($post->ID, 'traveldates' ,true);
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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc
— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.