Home › Forums › Pro Version › Custom query: how to show future events only? › Reply To: Custom query: how to show future events only?
October 12, 2016 at 1:53 pm #14683
Keymaster
Hi Ben,
For that you need to write a complex query for it and need to use filter. It should be like this and you need to keep in your functions.php of your theme file.
add_filter('wmlp_query', 'my_custom_query_wmlp',10,2);
function my_custom_query_wmlp($args, $shortcodeID){
if ($shortcodeID == 2){ //WHERE 2 should be replaced with your shortcode ID
$today = date('Ymd');
$args['meta_key'] = 'eventstart';
$args['meta_query'] = array(
array(
'key' => 'eventstart',
'value' => $today,
'compare' => '>='
)
);
$args['orderby'] => 'meta_value_num';
$args['order''] => 'ASC';
return $args;
}
}
Hope this helps. Also, please make sure your date is in YMD format.
Thanks