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

Reply To: Show/hide results based on a datetime metafield

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Show/hide results based on a datetime metafield Reply To: Show/hide results based on a datetime metafield

#52976
Ernest MarcinkoErnest Marcinko
Keymaster

Sure Samuele! I would also prefer a custom code snippet if I were you, good choice 🙂

This is what you are looking for:

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'     => 'start-date',
		'value'   => strtotime("today", time()),
		'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.