This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Getting Mixed Search Results and Need Help with Filter Menu

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Getting Mixed Search Results and Need Help with Filter Menu Reply To: Getting Mixed Search Results and Need Help with Filter Menu

#38521
Ernest MarcinkoErnest Marcinko
Keymaster

Thank you for the details!

I managed to resolve the isotope issue. There was actually a line of code in that script file, which automatically queried elements with “data-masonry” attributes. That attribute was actually present on that posts list container – so isotope simply started to use that element as well. With a bit of debugging I found the line and removed it. The issue immediately went away. I will include this in the upcoming patch of course.

The issue with the filters is a bit different though. The values entered into those fields are indeed not numeric. They are almost perfect, but there are spaces and “,” commas – which immediately makes them a string. Whenever using a numeric database operator – like the “between” in case of the range slider filter, the stored values have to be pure numeric – otherwise Mysql/MariaDB “quick” converts them to numbers during query, and that is not good.
A numeric value in this case means numbers only, and for decimals a dot “.” as the decimal separator, like 123, 123.25, 0.1234 etc..
Adding thousand separators (like spaces, commas etc..) will change the actual value. For example “1,2345” is not considered as “12345” but simply “1” (everything removed after the first non-numeric character during casting). This happens on the database level, that is not possible to affect unfortunately.

For storing information it is always the best to use the proper format. For numbers I recommend using numbers only without any formatting. Formatting should be always done when the value is displayed.

If you are planning to use that data for filtering purposes (with whichever plugin or future code or anything) the data should be rather converted to actualy numbers. ACF may actually have a number input, although I don’t exactly know if switching an existing field to that will automatically convert every previous value to numbers – but it is a great way to restrict the input to actual numbers only.