This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: can I exclude past events?

#53195
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

Yes! It is possible via a custom code snippet:

add_filter("asp_query_args", "asp_query_args_apply_date", 10, 2);
function asp_query_args_apply_date($args, $search_id) {
	$args['post_meta_filter'][] = array(
		'key'     => '_EventStartDate',
		'value'   => date('Y-m-d'),
		'operator' => '>=',
		'allow_missing' => false
	);
	return $args;
}

Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

If you are using the snippets plugin, make sure the code can run everywhere.