Results sorted by relevance

Forums › Forums › Search & Filter Pro › Results sorted by relevance

Viewing 4 posts – 1 through 4 (of 4 total)
  • Anonymous
    #268633

    Hi,

    I have a search form set up with results displayed via shortcode. When I enter a search term the results arn’t displayed in order of relevance. If I add relevance as a manual sorting option, that works, but i’d like the initial search results to disply like this automatically.

    I’ve selected Default Order as revelance descending under “Posts” tab but still not working. Any ideas?

    I have the Enfold theme.

    Many thanks,

    Chris

    Trevor
    #268666

    You might also need to use the Relevanssi plugin. The documentation for this is here:

    https://www.designsandcode.com/documentation/search-filter-pro/3rd-party/relevanssi/

    You would need to install and activate the free Relevanssi plugin as well.

    Then set Relevanssi up and build its index (make sure it is indexing the desired post types, custom fields AND any taxonomy that you want to search).

    Anonymous
    #268672

    Thanks Trevor, managed to fix it with the following:

    function relevant_search_result( $q ) {
    if ( is_search() && is_main_query() )
    $q->set( 'orderby', 'relevance');
    }
    add_action( 'pre_get_posts', 'relevant_search_result' );
    Trevor
    #268674

    Great to see it is sorted for you. I will close this thread for now.

Viewing 4 posts – 1 through 4 (of 4 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.