Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Can't put events in date order in search results › Reply To: Can't put events in date order in search results
November 21, 2022 at 1:02 pm
#40054
Keymaster
Well this is a tough one, but I guess the best approach is via a custom code.
Try adding this code 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.
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' => 'mec_end_date',
'value' => date("Y-m-d"),
'operator' => '>',
'allow_missing' => false
);
return $args;
}
I don’t know if this is going to do anything, but it should remove any items from the results, which have the end date before the current date.