Home › Forums › General Issues › Date Picker (and if date specified has passed) › Reply To: Date Picker (and if date specified has passed)
Hey guys. I’m facing this same problem, and I was able to apply @rdck solution on the “single-event page”, but not on the “loop of all events” page.
I need to check if the date of every event showed on the loop page has already passed and add an class to the <div class="evento-thumbnail">
My loop page:
<div class="conteudo-eventos-out">
<div class="conteudo-eventos-in">
<?php $loop = new WP_Query( array( 'post_type' => 'evento', 'posts_per_page' => -8, 'post_status' => 'publish' ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="evento-thumbnail"><?php echo get_the_post_thumbnail(); ?></div>
<div class="evento-titulo"><p><?php echo the_title(); ?></p></div>
<div class="evento-data">
<?php if ( get_field('event_start_date') && get_field('event_end_date') ) : ?>
<?php $start_date = DateTime::createFromFormat('Ymd', get_field('event_start_date'));
$end_date = DateTime::createFromFormat('Ymd', get_field('event_end_date')); ?>
<p class="date">Data: <?php echo $start_date->format('d/m'); ?> até <?php echo $end_date->format('d/m'); ?></p>
<?php elseif ( get_field('event_start_date') ) : ?>
<?php $start_date = DateTime::createFromFormat('Ymd', get_field('event_start_date')); ?>
<p class="date"><?php echo $start_date->format('d/m'); ?></p>
<?php endif; ?>
<?php endwhile; wp_reset_query(); ?>
</div>
</div>
</div>
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.