How to remove Wooevents passed events from category & shop pages
A lot of people used Wooevents plugin. Today I will show you how easy it is to remove passed wooevents plugin from website frontend for users. The issue is when an author creates events throw Wooevents for people and events passed. People still able to book events which is not good. Author of website always trying to find the good way that how to easily and automatically remove passed events from there category and shop pages. I will provide you function that will remove events from your category and shop pages. Please see below how to add code.
function show_ucomingevent_shop_loop( $query ) {
$time_now = strtotime("now");
if ( ! is_admin() && (is_shop() || is_product_category() && $query->is_main_query() || is_product_tag()) && $query->is_main_query()) {
$meta_valu = array(
array(
'key' => 'we_startdate',
'value' => $time_now,
'compare' => '>=',
),
);
$query->set('orderby', 'meta_value_num');
$query->set('order', 'ASC');
$query->set('meta_key', 'we_startdate');
$query->set('meta_query', $meta_valu);
}
}
add_action( 'pre_get_posts', 'show_ucomingevent_shop_loop',99 );
Just add this code in your theme function.php file and you are done. It will remove all past events from your events/products list. Hope you guys like it.
Always stay tune with Sensod Forum with the latest update about development.