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
February 19, 2025 at 7:34 pm
#52976
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.