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

Reply To: Help with asp_query_args() filter not querying meta_key vale as dates

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Help with asp_query_args() filter not querying meta_key vale as dates Reply To: Help with asp_query_args() filter not querying meta_key vale as dates

#25348
Ernest MarcinkoErnest Marcinko
Keymaster

Hi!

That solution looks okay, but there is another way, so no WP_Query is required, saving some performance.

The date filters are indeed not documented, sorry about that. The numeric operators automatically will force the value to a numeric. Can you please try this variation:

add_filter("asp_query_args", "asp_query_args_change", 10, 2);
function asp_query_args_change($args, $search_id) {
	// Do your stuff with the $args array
	// ....  
	if($search_id == '1'){
		$date = date('Y-m-d');
		$args['post_meta_filter'] = array(
			array(
				'key'     => '_EventStartDate',
				'value'   => $date,
				/**
				 * Operators that should work:
				 * before, before_inc, after, after_inc, match, nomatch
				 */
				'operator' => 'after_inc'
			)
		);
	}
	return $args;
}