Compatibility with the Avada theme

Avada is the most popular WordPress theme on the market. Unfortunately it doesn’t work with Relevanssi out of the box. The reason for the incompatibility is the most common there is: there’s an unnecessary query_posts() call in the search.php file. To make Relevanssi work, make the following change to the search.php file. Find this line:

query_posts($query_string.'&posts_per_page='.$smof_data['search_results_per_page'].'&paged='.$page_num);

And either remove it or comment it out (by adding // in front of the line). Since an update will overrun any changes you’ve made, this is best done in a child theme.

Update 2.7.2015: Looks like Avada is compatible with Relevanssi from version 2.8 on (approximately).

Update 11.1.2016: Avada 3.8.4 should work without problems with Relevanssi.

Update 19.1.2016: Avada 3.9.1 should work without problems with Relevanssi.

  • avidal

    hi, unfortunately i still cant make your plugin work with avada? i ha ve deleted the suggested line in search.php and it is still not able to find any results at all.

    any suggestions?

    indexing:

    Documents in the index: 234
    Terms in the index: 9017
    Highest post ID indexed: 1803

    • Can you show me the complete search.php in your theme? Put it in a pastebin and link here.

      • avidal

        here you go:

        http://pastebin.com/WnNEFMsB

        thanks alot

        • There are no problems with your search.php, so it’s something else. Is your site perhaps limiting the search somehow to a particular category or a post type?

          • avidal

            i doubt it before installing your plugin i was getting search results from post, pages, and custom post type within title and content.
            the only reason i installed relevanssi is because i want the search results to include Custom Field for my custom post type

            thank you,

          • Well, something’s off, it’s not in your search.php file and that’s just about all I can say without seeing your site.

          • avidal

            Alright, I’ll see if I can find an alternative solution.

            Your plugin looked very good tho.

            Thank you

  • Hello, seems like Relevanssi is broken again with Avada (v3.8), sadly. They changed the search.php so much that above mentioned fixed doesn’t apply anymore. Here’s the new search.php: http://pastebin.com/VaaSe9Mw
    A fix would be highly appreciated, thanks a lot!

    • Hi, nothing wrong with that search.php template. I’d need to see a complete site with the theme, with the ability to edit template and plugin files, to figure out if there’s a solution.

  • gezonde recepten

    I can confirm that the “did you mean” is broken with with Avada v3.9.2. If there is anything I can do to assist (test, provide details, etc), please let me know.

    • Does the search work otherwise? How exactly is the “did you mean” broken?

      • gezonde recepten

        I have added <?php if (function_exists('relevanssi_didyoumean')) { relevanssi_didyoumean(get_search_query(), "Did you mean: ", "", 5);" to the search.php in the Child Theme. I’ve put it before the have_posts(). It however does appear to do anything.

        I do see search requests being logged at Dashboard > User searches.

        I also excluded some pages from the search and that works too.

        PS off topic: the search hit highlighting doesn’t seem to work either with the avada theme.

        • I’d need full access (WP Admin and FTP) on a site, or a copy of the theme.

          • gezonde recepten

            Can you send me an e-mail (carlo.kool@gmail.com) so I can provide you with the details required? Or do you provide a different medium to exchanges this?

          • The Did you mean function works as it should when I try it. If you’re using the free version of Relevanssi, do note that it requires a good amount of logged queries in order to work well. If user logs are not enabled, it doesn’t work at all, and if there are not enough logs, it can’t always suggest good results.

            Premium has a much better Did you mean function that doesn’t require logs and instead uses the database as the source for corrections.

            Search hit highlighting works with the default Avada child theme, no problems. You may want to disable “Strip HTML from Excerpt” option under Blog settings in Avada, but it wasn’t necessary when I tried it, I still got the highlights with no problems.

          • gezonde recepten

            My website is live now and the amount of logged queries is growing. Now the “did you mean” is indeed working. Thank you for your assistance in this matter.

            I simply impelemented the following code in the search.php using the Avada Child theme:

            <?php if (function_exists('relevanssi_didyoumean')) { relevanssi_didyoumean(get_search_query(), "<p>Did you mean: ", "</p>", 5); }?>

            I hope this posts helps others too.

          • lerr

            Hi. I use that theme (3.9.1 version). Can you tell me, in what line of search.php i should insert your code? What else should i do to make that search plugin work?

  • lerr

    My friends, can you give step by step insruction how to implement search in the newest avada theme.
    I put code from gezonde recepten
    to search.php in avada theme folder. But it broke search completely. What am i doing wrong?

  • lerr

    So my search.php looks like that

    <div id="content" layout->add_class( ‘content_class’ ); ?> layout->add_style( ‘content_style’ ); ?>>

    settings->get( ‘search_new_search_position’ ) == ‘bottom’ ) {

    get_template_part( ‘templates/blog’, ‘layout’ );

    ?>

    settings->get( ‘search_new_search_position’ ) != ‘hidden’ ) : ?>

    <div class="search-page-search-form search-page-search-form-settings->get( ‘search_new_search_position’ ); ?>”>

    <form class="searchform seach-form" role="search" method="get" action="”>

    <input type="text" value="" name="s" class="s" placeholder="”/>

    settings->get( ‘search_new_search_position’ ) == ‘top’ || Avada()->settings->get( ‘search_new_search_position’ ) == ‘hidden’ ) {

    get_template_part( ‘templates/blog’, ‘layout’ );

    }

    ?>

    template->title_template( $title );

    ?>

    settings->get( ‘checklist_circle’ ) ) {

    $circle_class = ‘circle-yes’;

    } else {

    $circle_class = ‘circle-no’;

    }

    wp_nav_menu( array( ‘theme_location’ => ‘404_pages’, ‘depth’ => 1, ‘container’ => false, ‘menu_class’ => ‘error-menu list-icon list-icon-arrow ‘ . $circle_class, ‘echo’ => 1 ) );

    ?>

    <?php get_footer();

    // Omit closing PHP tag to avoid "Headers already sent" issues.


    How I should change it? Please paste as comment if possible. Thanks in advance.