Search By First Letter Only

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search By First Letter Only

This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 6 years, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #15792
    bboyd96
    bboyd96
    Participant

    Hi,

    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

    Attachments:
    You must be logged in to view attached files.
    #15813
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #15828
    bboyd96
    bboyd96
    Participant

    #1 works perfectly. Thanks so much for your prompt and helpful response!

    #15829
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.