Support » Plugin: ACF: Better Search » Search whole words only

  • Resolved codemonkeynorth



    if I search ‘oug’ it matches pages with ‘through’ on them.

    Would be great if we could have a setting to ‘match whole words only’

    there’s an implementation here as an idea although some of the code is deprecated

    essentially replacing eg
    $list[] = 'd.post_title LIKE \'%' . $word . '%\'';
    $list[] = 'd.post_title REGEXP \'[[:<:]]'.$word.'[[:>:]]\'';


Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mateusz Gbiorczyk


    Hi @codemonkeynorth,

    Thank you for your message.

    You can do this with the posts_search WordPress filter and create the appropriate regex in it. But that is a very good idea. I will try to implement it in the new version of the plugin.

    This functionality will appear in the latest version of the plugin.

    If you have the opportunity, please test the beta version and give your feedback:

    seems to work well so far. I’ll give it a thorough test tomorrow.

    as per my example “oug” now does not bring back search results, but “through” does… which is what we want

    it also picks up a search for “studies” when the copy is “… studies.”, so it’s correctly ignoring punctuation there which I’d expect from that expression.

    I know regex is supposedly slow, but it’s alright mostly

    thanks for looking into this!

    Plugin Author Mateusz Gbiorczyk


    @codemonkeynorth, please run tests and let me know if I can help you with anything else.

    Plugin Author Mateusz Gbiorczyk


    @codemonkeynorth Unfortunately, I have not received any response from you. I have released a plugin update – please download it and test the search.

    If there is a problem, let me know. If I do not receive an answer within the next 7 days, I will close the thread, considering the problem to be resolved.

    Hi Mateusz,

    sorry we’ve been tied up with deadlines!

    All seems good so far, I’ll test this new release out on our dev site

    thanks again for your work

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Search whole words only’ is closed to new replies.