<?php
$args = [
    'post_type' => 'event',
    'post_status' => 'publish',
    'posts_per_page' => 4,
    'meta_query' => [
        [
            'key' => 'event_date',
            'compare' => '>=',
            'value' => date( 'Ymd' )
        ]
    ]
];

$wpb_all_query = new WP_Query( $args );
?>

							<?php if ( $wpb_all_query->have_posts() ) : ?>

							<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>


									<?php $raw_date = get_field('event_date', false);
									   $today = date('Ymd');

									   if ($raw_date < $today) {
									     // skip it
									     continue;
									   }

									   $date = DateTime::createFromFormat('Ymd', get_field('event_date'));
									   $subtitle = get_field('event_subtitle');
									   $starttime = get_field('start_time');
									   $endtime = get_field('end_time');
									   $location = get_field('location');
									   $price = get_field('price');
									   $link = get_field('book_link');
									   $button = get_field('book_button');

									   ?>
									   <div class="event-feed event-main-feed">
									   		<div class="event-date-holder ilb vat relative">
										   		<div class="absolute">
											   		<div class="table">
												   		<div class="cell vam tac">
														   	<p class="light text-grey event-day"><?php echo $date->format('d'); ?></p>
														   	<p class="demi uppercase event-month-year"><?php echo $date->format('M'); ?> '<?php echo $date->format('y'); ?></p>
												   		</div>
											   		</div>
										   		</div>
										   	</div><div class="event-info-holder demi uppercase ilb vat relative">
											   	<div class="text-green ls2"><?php the_title(); ?></div>
											   	<div class="text-grey ls2 pb20"><?php echo $subtitle; ?></div>
											   	<div class="event-book-button"><a class="button" href="<?php echo $link; ?>" target="_blank"><span class="z100 relative"><?php if( $button ): ?><?php the_field('book_button'); ?><?php else: ?>Book event<?php endif; ?></span></a></div>
											   	<?php if( $starttime ): ?><div class="text-grey ls2"><span class="text-green">•</span> <?php echo $starttime; ?> - <?php echo $endtime; ?></div><?php endif; ?>
											   	<?php if( $location ): ?><div class="text-grey ls2"><span class="text-green">•</span> <?php echo $location; ?></div><?php endif; ?>
											   	<?php if( $price ): ?><div class="text-grey ls2"><span class="text-green">•</span> <?php echo $price; ?></div><?php endif; ?>
										   </div>

										   <?php $the_content = apply_filters('the_content', get_the_content());
											  if ( !empty($the_content) ) { ?>
											    <div class="event-description pt20"> <?php echo $the_content; ?></div>
											<?php  } ?>
								</div>
							<?php endwhile; ?>

							<?php wp_reset_postdata(); ?>

							<?php else : ?>

						<?php endif; ?>