Hi Luo ,
Pls look into this tutorial link :
hidden link
i would like to implement this for my search form fields , the field are property-price and property-size.
I am not sure how to add this functions, can you guide me along please.
i will try on my end too.
thank you.
Dear C6410,
I assume you are going to format the user input number with comma, for example "12,456", the link you provided is a JS solution, which works in front-end, it will be able to turn the numeric value "12345" into string value "12,456", but it will pass URL parameter as string value to Views in server side, so it will conduct unexpected problem, for example, in your website:
without comma, just numeric value 12345
hidden link
and with comma, string value 12,345
hidden link
There are other unexpected results.
So it is not recommended to use the scripts you mentioned above.
Hi. I understand this issue .
Do you have other way to achieve this ? Thanks.
There should be other workaround, for example when user submit the form, and pass URL parameter with string value "12,345" to Views, you can try with Views filter hook wpv_filter_query to trigger a custom PHP function. in this PHP function do these:
1) Get the string value, and remove the comma, turn it into numeric value
2) pass it to Views query
See our document
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
wpv_filter_query
When displaying a View listing posts, this filter is applied to the arguments being generated by the View settings before they are passed to the WP_Query class.
But since it is not the built-in feature of Views plugin, it will make things complicated, only for your reference.
Thanks for the details. does this extra code increase server resources ?
appreciate if there is any sample code ,meanwhile ill try something my end too. thank you.
Q1) does this extra code increase server resources ?
The extra code will spend some server resources, but it should not conduct performance problem.
Q2) if there is any sample code
In the document:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
click link "Usage examples", you will be able to see the example codes of how to use filter hook "wpv_filter_query"
Ok, thanks. ill try and update you the code soon. cheers
OK, please update this thread if you need more assistance for it. thanks