Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Convert large numbers for the Range Slider › Reply To: Convert large numbers for the Range Slider
May 3, 2021 at 1:26 pm
#33064
Keymaster
Hi,
Interesting question. I think the best possible approach is to use the range slider as 1 to 2000 and add the “million” as the suffix. Then using a custom code right before the search multiply the values by 1000000.
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_change", 10, 2);
function asp_query_args_change($args, $search_id) {
$field = "meta_field_name"; // enter the field name here
foreach( $args['post_meta_filter'] as &$filter ) {
if ($filter['key'] == $field && is_array($filter['value'])) {
foreach ($filter['value'] as $k=>&$v) {
$v = $v * 1000000;
}
}
}
return $args;
}
Don’t forget to change the $field variable to the field name.