- December 7, 2017 at 10:45 pm #15792
I have a question regarding the features/capabilities of your plugin. I am creating a staff directory search, and would like to be able to search by first letter of a name only. When I type in a letter, it displays all the results containing that letter, whether it is the first letter or somewhere in the middle.
Is your plugin capable of, when the user types in a letter, checking only the first letter of a page title and displaying only the results that contain that letter as the first letter? I am working specifically with pages, not posts or projects. If your plugin can do this, how is it done?
The screenshot I included shows what I do not want. If I type in an “L”, I want to only be able to see results that start with “L”.
Attachments:You must be logged in to view attached files.December 8, 2017 at 1:45 pm #15813
Well, there are two possibilities at this moment, one is exactly what you need, but it requires editing one file, the other one is close to what you need, but does not require editing.
Solution #1: Exact matching with a small file edit
First, you will have to enable exact matches on the General Options -> Logics & Behavior panel: https://i.imgur.com/JlIhVR8.png
Then only allow searching the title: https://i.imgur.com/g5emOnf.png
– Make sure to have a back-up copy of everything, just in case.
– Open up the wp-content\plugins\ajax-search-pro\includes\classes\search\class-asp-search-cpt.php
– Scroll down to line 493, which should be this:
– Change that line to this:
– Save the file, and it’s done.
Solution #2: Using the index table engine
The index table engine only matches word starts or reverse match endings. So by typing in ‘a’ it will only yield results if any of the field keywords starts with or ends with ‘a’. It will give less results, but not as close to the previous solution.
Personally, I would suggest solution #1. I will try to implement an option to choose the exact match location in the future, so this change won’t be neccessary.Best,
If you like my products, don't forget to rate them on codecanyon :)
December 10, 2017 at 11:46 pm #15828
#1 works perfectly. Thanks so much for your prompt and helpful response!December 11, 2017 at 6:49 am #15829
You must be logged in to reply to this topic.