Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Help with Search Variation
This topic contains 2 replies, has 2 voices, and was last updated by louiepelon 8 years, 9 months ago.
- AuthorPosts
- November 14, 2015 at 1:37 am #6630
Please take a look at the attached screenshot. I have a tire section to where I would like the search show results no matter how the variation is entered. For example, a tire tire is normally 225/40R18. My title (screenshot) has this variation, BUT I want to be able to search as 2254018 WITHOUT the / and R. How would that be possible? I do not want to alter my title.
Thank you in advance.Luis
Attachments:
You must be logged in to view attached files.November 14, 2015 at 8:12 am #6632Hi!
Luckily you don’t have to alter your titles. The plugin code has a so called “filter point” before and after the search phrase is processed and sent to the database. This allows to create custom codes to make modifications to the search phrase, without actually changing anything in the plugin code.
I’ve quickly put together a function, that should help you with this. Put this code to your themes functions.php file (it should be in your active theme directory):
add_filter( 'asp_search_phrase_after_cleaning', 'remove_slash_and_r', 1, 1 ); function remove_slash_and_r( $phrase ) { $temp_phrase = str_replace(array("/", "R"), "", $phrase); if ($temp_phrase != $phrase) $phrase = $phrase . " " . $temp_phrase; return $phrase; }
This code replaces “R” or “/” characters in the search phrase, then compares it to the original. If they are different, then it appends the one without the “R” or “/” characters.
Basically if the user types in “225/40R18” the search will register it as “225/40R18 2254018”, so it will search for 2554018 as well.Let me know how this works!
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 14, 2015 at 8:43 am #6633This most definitely works! Thank you Ernesto. Fast service and response
- AuthorPosts
You must be logged in to reply to this topic.