Search By First Letter Only
Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Search By First Letter Only
- This topic has 3 replies, 2 voices, and was last updated 8 years, 7 months ago by
Ernest Marcinko.
-
AuthorPosts
-
December 7, 2017 at 10:45 pm #15792
bboyd96
ParticipantHi,
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”.
Thanks,
bboyd96
December 8, 2017 at 1:45 pm #15813Ernest Marcinko
KeymasterHi!
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
Then:
– 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.
December 10, 2017 at 11:46 pm #15828bboyd96
Participant#1 works perfectly. Thanks so much for your prompt and helpful response!
December 11, 2017 at 6:49 am #15829Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- You must be logged in to reply to this topic.