Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Slider Range with two custom fields? › Reply To: Slider Range with two custom fields?
Hi,
Well, I’m afraid this is not possible, maybe via a custom code. I have constructed a possible solution, but I could not test this, so be very careful. Make sure to create a range slider for the minTimezone custom field for this to work. The code will automatically identify and then separate it to two individual min/max query arguments with the correct fields right before the search.
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.
add_filter("asp_query_args", "asp_query_args_change", 10, 2);
function asp_query_args_change($args, $search_id) {
global $wpdb;
foreach ( $args['post_meta_filter'] as $k => $filter) {
if ( $filter['key'] == 'minTimezone' ) {
$min = $filter['value'][0];
$max = $filter['value'][1];
unset($args['post_meta_filter'][$k]);
// add the min
$args['post_meta_filter'][] = array(
'key' => 'minTimezone',
'value' => $min,
'operator'=> '>=',
'allow_missing' => false
);
// add the max
$args['post_meta_filter'][] = array(
'key' => 'maxTimezone',
'value' => $max,
'operator'=> '<=',
'allow_missing' => false
);
break;
}
}
return $args;
}