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
January 18, 2020 at 9:43 pm
#25344
Participant
Ok I have gone away and thought about other ways, as a self taught developer I have only one mindest and that is to find the solution if I can and when I cant I turn to the expert but I think I found the solution, however, can you let me know if this is ok to run, it gives me the results I want and filters nicely at this stage
add_filter("asp_query_args", "asp_query_args_change", 1, 2);
function asp_query_args_change($args, $search_id) {
// Do your stuff with the $args array
// ....
// Then return
$eventdate= date('Y-m-d');
$loop = new WP_Query(array(
'post_type' => array('tribe_events'),
'posts_per_page' => -1,
'orderby' => 'meta_value',
'order' =>'DESC',
'fields' => 'ids',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_EventStartDate',
'value' => $eventdate,
'compare' => '>=')
)
)
);
$upcoming_events = $loop->posts;
wp_reset_postdata();
if($search_id == '1'){
$args['post_in'] = $upcoming_events;
}
return $args;
}
Hope this helps others