Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #229857

    I’m in the process of finishing up a development site before I move it to a live environment. I absolutely love the Enfold theme and have been able to, thus far, build a beautiful site using it (still have a lot left to finish unfortunately).

    EDIT: I’m using the newest/latest version of Enfold, Version 2.5.2

    Anyway, I installed Relevanssi and now my “instant search” results that Enfold serves up via Ajax do not match those results on the actual search results page. Within the Relevanssi settings I input specific page ID’s that I do not want returned in the search results. On the search results page, those pages I don’t want to appear in the search results don’t appear, which is great.

    However, they are still appearing within the “Instant Search” results. This is very bad, because I have pages that should only be seen by customers of mine (like “Thank you for purchasing”, “Reduced Special Pricing Pages” and so on).

    After searching the forums, I found a few posts detailing similar issues. I included the following code which I found on this post: https://kriesi.at/support/topic/enfold-code-update-for-2-2-to-use-relavanssi-plugin/ within my themes functions.php file (at the very bottom of it, beneath everything else within the file)

    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;
    
        $tempquery->query_vars = $search_parameters;
        relevanssi_do_query($tempquery);
        $posts = $tempquery->posts;
    
        return $posts;
    }

    Unfortunately, that doesn’t work. I still am seeing pages that I specified within the Relevanssi settings as pages to not be returned in search results within the “Instant Search” results returned (but again, the pages I specified within the Relevanssi settings to not be returned in search results DO NOT appear on the actual search results page, which is correct…but they’re still appearing within the instant search results).

    • This topic was modified 10 years, 10 months ago by crazyflx.
    #229870

    Hey crazyflx!

    Add it to the top of your functions.php file just under: if(isset($avia_config['use_child_theme_functions_only'])) return;

    Regards,
    Devin

    #229874

    Hello Devin!

    Thanks so much for the quick reply, I really appreciate it. Unfortunately, it hasn’t yielded any different results. Here is what the beginning of my enfold functions.php file looks like (beyond what I’ve copy/pasted here, there are now zero changes…it’s exactly as it comes in a fresh download):

    <?php
    
    global $avia_config;
    
    /*
     * if you run a child theme and dont want to load the default functions.php file
     * set the global var bellow in you childthemes function.php to true:
     *
     * example: global $avia_config; $avia_config['use_child_theme_functions_only'] = true;
     * The default functions.php file will then no longer be loaded. You need to make sure then
     * to include framework and functions that you want to use by yourself. 
     *
     * This is only recommended for advanced users
     */
    
    if(isset($avia_config['use_child_theme_functions_only'])) return;
    
    /* adding filter for instant search to return relevanssi filtered pages/posts */
    
    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;
    
        $tempquery->query_vars = $search_parameters;
        relevanssi_do_query($tempquery);
        $posts = $tempquery->posts;
    
        return $posts;
    }
    
    /*end relevanssi filter */
    #229875

    EDIT: forgot to make private

    • This reply was modified 10 years, 10 months ago by crazyflx.
    #229878
    This reply has been marked as private.
    #229954

    Hi!

    You can try this code instead:

    
    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)
    {
        $tempquery = new WP_Query();
        $tempquery->query_vars = $search_parameters;
        relevanssi_do_query($tempquery);
        $posts = $tempquery->posts;
    
        return $posts;
    }
    

    It will make sure that a new query object will be used and the main query won’t affect the search query. If it doesn’t work please contact the plugin author for help because maybe it’s a limitation of the relevanssi_do_query() function and you can’t use it to exclude pages from the search query: http://www.relevanssi.com/knowledge-base/relevanssi_do_query/ . In this case some custom development might be required.

    Best regards,
    Peter

    #230759

    Hello Dude,

    Thanks very much for your help, I appreciate it. Unfortunately, that did not work either. It yields the same results as the previously entered code.

    My entered page ID’s (as entered within the Relevanssi settings) that should be excluded from search results are successfully excluded from the search results on the actual WP search results page. They are still being returned in the “instant search” results by enfold though.

    Thanks again for the help…do you think you could point me in the right direction with what I should be asking the folks over at Relevanssi?

    #231003

    Hey!

    During my tests the relevanssi_do_query() function always returned the same results for the ajax search and the standard search but I didn’t test the “exclude page” option. I’d ask if there’re any limitations of the relevanssi_do_query() function which may effect the search results and produce a different result. You can also ask how (and if) you can add the excluded page ids to the search query somehow – i.e. the post__not_in parameter should enable you to exclude some pages/posts but I’m not sure how you can retrieve the excluded entries list from Relevanssi, etc.

    Regards,
    Peter

    #345547

    Hi guys,

    crazyflx, did you ever end up solving this? I’m having the same issue right now…

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Search Results Not Matching "Instant Search" Results After Installing Relevanssi’ is closed to new replies.