How to skip or remove Passed events from custom wordpress woocommerce Query in Wooevents Plugin.

Hi,
I Wrote query that fetch events from one of my Woocommerce category. But problem is my query get passed events too with upcoming events. i just don't want to show passed events. So user will not get confused and able to booked passed events. Here is my query.

$my_query = new WP_Query(array( 'post_type' => "product", 'product_cat' => 'events' ));
if ( $my_query->have_posts() ):
while ( $my_query->have_posts() ):
$my_query->the_post();
global $product;
//Book Now Code Here
endwhile; endif;
wp_reset_query();
Nov 1, 2017
Wordpress Bugs

Experts Replied:

Sensod Developer

Sensod Developer

Replied on: Nov 1, 2017
Hi,
Before few days i made query something like that. Hope this will work perfectly. Please have a look below.
$my_query = new WP_Query(array( 'post_type' => "product", 'product_cat' => 'events' ));
if ( $my_query->have_posts() ):
while ( $my_query->have_posts() ):
$my_query->the_post();
global $product;
$xml .= '' . $product->get_display_price( $product->get_regular_price() ) . '';
$xml .= '' . $product->get_display_price() . '';

$we_startdate = we_global_startdate();;
$we_enddate = we_global_enddate() ;
//remove button if event pass
$time_now = strtotime("now");
$we_layout_purpose = we_global_default_spurpose();

$we_time_zone = get_post_meta($post->ID,'we_time_zone',true);
if($we_time_zone!='' && $we_time_zone!='def'){
$we_time_zone = $we_time_zone * 60 * 60;
$time_now = $we_time_zone + $time_now;
}

if($time_now > $we_enddate && $we_enddate!='' && $we_layout_purpose=='event'){
//Leave This Empty
}else{
//Write your Button Code Here
} endwhile; endif; wp_reset_query();

Thank you
Matthew

Matthew

Replied on: Nov 1, 2017
Hi Sensod Developer,
I just spend alot of time to find solution for my custom query. Thank you for your hard work and share publicly. It's worked great. I just go throw and saw you get event start and end time and set with if condition. i really appreciate that.
Thank you

Topic mark as closed!