• Hello,
    I’m using Enfold, one of the most widespread WP themes, and I have noticed a striking discrepancy on the search results between the “classic” Relevanssi search and the Ajax-driven “Instant Search” used by default on the theme.
    In short, the Instant Search does not match the actual entries normally indexed by Relevanssi.

    The theme’s authors suggested to add the following code to function.php:

    add_filter('avf_ajax_search_function', 'avia_init_relevanssi', 10, 4);
    function avia_init_relevanssi($function_name, $search_query, $search_parameters, $defaults)
    {
        $function_name = 'avia_relevanssi_search';
        return $function_name;
    }
    
    function avia_relevanssi_search($search_query, $search_parameters, $defaults)
    {
        global $query;
        $tempquery = $query;
        if(empty($tempquery)) $tempquery = new WP_Query();
    
        $tempquery->query_vars = $search_parameters;
        relevanssi_do_query($tempquery);
        $posts = $tempquery->posts;
    
        return $posts;
    }

    But that didn’t solved the problem.

    I tried to ask for help to the theme’s developer, and he replied: “I am afraid you’ll need to contact the plugin author for more info about the issue. Making third-party plugins compatible with the theme is unfortunately beyond the support scope we offer.”

    Does anybody have any suggestion on how to allow Enfold’s “Instant Search” match the entries indexed by Relevanssi?

    Thanks for your help!

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Adding that code doesn’t change the results at all?

    That seems to be the way to replace the Enfold Instant search with another search engine, but if it doesn’t work, then I’m afraid I can’t help you.

    To debug this, I’d need to see what does the $tempquery variable contain when it’s passed to Relevanssi.

    Thread Starter Nightjar

    (@nightjar)

    I have asked the theme’s developers info about that $tempquery variable, In any case, they wrote:

    “Yes, unfortunately, the theme’s ajax search uses the get_posts function to query posts.”

    Does that mean that there is no way out of this loop for ajax search?

    Thanks!

    Plugin Author Mikko Saari

    (@msaari)

    The theme developers can’t tell what’s inside the $tempquery function on your site when you do the search.

    But this is the correct solution for replacing the instant search with Relevanssi, and it has worked for other people.

    Can you show me an example search where the instant search doesn’t find the correct results?

    Thread Starter Nightjar

    (@nightjar)

    Hello Mikko,
    here is what the developers say there is inside the $tempquery function:

    View post on imgur.com

    An here is a screenshot showing the striking difference between the results (21 to nil) on a full Relevanssi-driven search and an Ajax search:

    https://www.azfleet.info/docs/azf_relevanssi.jpg

    I hope this helps!

    • This reply was modified 6 years, 11 months ago by Nightjar.
    Plugin Author Mikko Saari

    (@msaari)

    Hmm, I thought it might be a post type issue, but those posts can be found when searching by the title.

    There are some debugging steps that could be done here. I’d like to see what this version of the file would print out in the PHP error log when searching for “caravelle”.

    function avia_relevanssi_search($search_query, $search_parameters, $defaults)
    {
        global $query;
        $tempquery = $query;
        if(empty($tempquery)) $tempquery = new WP_Query();
    
        $tempquery->query_vars = $search_parameters;
        error_log($tempquery);
        relevanssi_do_query($tempquery);
        error_log($tempquery);
        $posts = $tempquery->posts;
    
        return $posts;
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem with Enfold theme “Instant Search”’ is closed to new replies.