Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Extension › Reply To: Extension
October 15, 2020 at 10:27 am
#29808
Keymaster
Hi,
The problem with that is – that running an SQL query there is no way to compare values against an array, because the meta field is a string always, in this case it is the “array” serialized into a string value. Making changes to the actual filter is not going to work.
I think the best way to approach this is probably when the search is complete and remove the items in the post process via the asp_results filter. The $args array contains the filter values as well, so the date which the user selected.
Something to help you start with:
add_filter( 'asp_results', 'asp_remove_custom_res', 10, 4 );
function asp_remove_custom_res( $results, $id, $is_ajax, $args ) {
foreach( $args['post_meta_filter'] as $filter ) {
//var_dump($filter); // Check how this looks like
if ( $filter['key'] == 'meta_field_name' ) {
// $filter['value'] ->> this has the date value
// use this to exclude the items
/*
* foreach ( $results as $k => $r ) {
* if ( ... )
* unset($results[$k]);
* }
*/
}
}
return $results;
}