I am using a plugin called events manager. There is a custom post type called events, & each event has a date in a custom field. There is also a custom taxonomy called event categories.
On my site, all the events that have been assigned to a term in the event categories taxonomy, have an archive page. My code below shows these events on the archive pages. However, it also shows the events that have already passed, I only want it to show future events. How can I change my code to make this bit work, please?:
<?php
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $termst = $term->slug;
$today = getdate ();
$args = array(
'post_type' => 'event',
'tax_query' => array(
array(
'taxonomy' => 'event-categories',
'field' => 'slug',
'terms' => $termst,
'posts_per_page' => -1,
'meta_key' => '_event_start_date',
'meta_query' => array( array( 'meta_key' => '_event_start_date' , 'meta_value' => $today, 'compare' => '>=' , 'type' => 'date')),
'orderby' => 'meta_value'
),
),
);
$query = new WP_Query( $args );
if($query ->have_posts()) :
while($query ->have_posts()) :
$query ->the_post();
?>
<h1><?php the_title() ?></h1>
<?php echo ' - '. get_post_meta($id, '_event_start_date', true) ?>
<?php
endwhile;
else:
?>
Oops, there are no posts.
<?php
endif;
?>