Support

Account

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&eacute; <?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>