Display Upcoming Events with ACF Date field
How to create the basic event listing page with ACF date field & Custom Post type. To make event ticker that wants to show only events that are happening on the current day or in the future day.
The below code helps you to create basic event listing page with ACF date field & Custom Post type.
<?php $args = array( 'post_type' => 'news_events', 'posts_per_page' => 3, 'tax_query' => array( array( 'taxonomy' => 'news_events_category', 'field' => 'slug', 'terms' => 'upcoming-events', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ) ); $event = new WP_Query( $args ); if( $event->have_posts() ) { while($event->have_posts()) : $event->the_post(); $today = date('Ymd'); $events_date = get_field('event_date'); if (strtotime($today) <= strtotime($events_date)) { ?> <li> Event on: <?php $date = get_field('event_date'); $date2 = date("F j, Y", strtotime($date)); ?> <?php echo $date2; ?> <a href="<?php the_permalink() ?>"> <?php the_title(); ?> </a> </li> <?php } endwhile; ?> <?php } ?>