- November 21, 2016 at 5:51 am #10943
I have some products on my site which have ‘VX-3’ as part of their name and in their content. If I search for VX-3 I get a list of all the products to choose from. However I would like the user to be able to type in VX3 (without the dash) and get the same results. Is this possible? I have spent hours on altering th behaviour settings without any luck.
Also, currently when you do type in VX3 I get a list of ‘Did you mean:’ suggestions, which don’t mean anything. how do I stop this?
Chris.November 21, 2016 at 3:12 pm #10949
Because the data is stored as “VX-3” there is no possible way of matching it with “VX3” without making a modification to the search phrase of some sort. MySQL does not support so called close matching inbetween a string.
The only possible solution is to perhaps use a custom code to watch the search phrase and change it if neccessary according to a pattern. I’m guessing in your case changing “XYZ123” to “XYZ-123” would be the solution. In this case I would recommend putting the following code to the functions.php file in your theme directory:
I have not fully tested this solution, so please be careful. It should put a dash character before any number that is adjacent to a non-numeric character.Best,
If you like my products, don't forget to rate them on codecanyon :)
You must be logged in to reply to this topic.