Basic events listing, ordered by date, past events disappearing.
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$today = date('Ymd', strtotime('-6 hours'));
$eventslist= new WP_Query( array(
'post_type' => 'events',
'posts_per_page' => 6,
'paged' => $paged,
'meta_key' => 'event_start',
'orderby' => 'meta_value',
'order' => 'ASC', //sort with soonest items at top
'meta_query' => array(
array(
'key' => 'event_end',
'meta-value' => $value,
'value' => $today,
'compare' => '>=', //stop showing event when past
'type' => 'CHAR'
)
)
);
if ($eventslist->have_posts()) :
while ( $eventslist->have_posts() ) : $eventslist->the_post();
Custom fields and HTML here to display listing
endwhile;
else :
echo '<p>There are no upcoming events.</p>';
endif;
wp_pagenavi( array( 'query' => $eventslist ) ); ?> //be sure wp-navi installed and activated!
wp_reset_query();
?>