Support » Plugin: Better Search » ACF Better search and Better search

  • Resolved Rozalia Stoilova

    (@rozaliastoilova)


    Hello,
    the plugin works perfectly, but I have to search in post meta fields (ACF custom fields) when I installed ACF Better search plugin it stopped work. If I deactivate Better Search plugin, the plugin starts to work again. Can you help me or give me some advice on how to fix the problem?

    Тhanks in advance.

    Cheers,
    Rozi

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello again,
    after short debugging, I found the main problem, no prefix ($wpdb->posts) is added to the query anywhere except at the beginning
    For Example:

    $field_score = ", (MATCH(post_title) AGAINST...

    should be replaced with

    $field_score = (MATCH({$wpdb->posts}.post_title) AGAINST...

    the same goes for other fields such as post_content, etc.

    Plugin Author Ajay

    (@ajay)

    That seems an unusual reason for the plugin to crash. Does that make it work again when you added that?

    It looks like ACF Better Search modifies all the search queries similar to Better Search. I’m not sure what exactly is the resultant query that gets generated. I suspect it is a major deviation as both plugins add their code to it.

    You can install Query monitor plugin and you will see the errors.

    Plugin Author Ajay

    (@ajay)

    Thanks. I don’t have the install. But making this fix makes sense to me.

    Would be keen to see what errors did Query Monitor give you in your install

    Plugin Author Ajay

    (@ajay)

    Thanks. That looks clear.

    I assume you have changed all the query instances in Better Search to fix the query? I’ll implement the similar changes

    Plugin Author Ajay

    (@ajay)

    I’ve implemented this in v2.2.1.

    Thank you very much,

    I have updated the plugin to the latest version and there is one last thing 🙂
    in bsearch_posts_fields function
    $fields = ' ID';
    should be replaced with
    $fields = " {$wpdb->posts}.id AS ID";

    Plugin Author Ajay

    (@ajay)

    Thanks. I’ve raised an issue for a subsequent fix.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘ACF Better search and Better search’ is closed to new replies.