Skip to main contentSkip to footer

If best results don’t come up first and changing weighting settings doesn’t seem to make any difference, there couple of things you can do.

Is Relevanssi active?

The first thing is to check if the results are actually provided by Relevanssi. If you disable Relevanssi, do the results change? Do you see Relevanssi-generated excerpts? There are different reasons why your search results may not come from Relevanssi even if Relevanssi is activated, and the most common has to do with query posts calls. For that, see this Knowledge Base entry.

Are the results in menu_order?

I’ve seen several cases where odd search results are caused by a theme (or a plugin) that forces the search to use menu_order, for some reason. If that’s the problem, the solution is simple. Add this code to your theme functions.php:

add_filter( 'relevanssi_orderby', function ( $orderby ) { return 'relevance'; } );

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Showing the number of search results

…$wp_query->found_posts . ‘ hits.</p>’; ?> in your search results template. In case that produces no results, try introducing the global $wp_query variable like this: <?php global $wp_query; echo ‘<p>Found ‘ . $wp_query->found_posts . ‘ hits.</p>’; ?> The usual method which involves a new WP_Query object does not work with Relevanssi….

Moving the admin search page
Jules Colle came up with a method of moving the Relevanssi admin search page from under the Dashboard heading to…
WooCommerce: Popularity and price sorting

Many WooCommerce users use search sorting that allows users to sort by popularity or price. Unfortunately, while Relevanssi works fine with WooCommerce, those sorts do not work. Relevanssi doesn’t know about price or popularity, and the sorting assumes there’s a default WP search underneath. Relevanssi doesn’t do meta field sorting…as easily as the default WP search does. This function handles price, popularity and rating sorting: add_filter( ‘relevanssi_orderby’, ‘woocommerce_relevanssi_orderby’ ); function woocommerce_relevanssi_orderby( $orderby ) { if ( in_array( $orderby, array( ‘price’, ‘price-desc’ ), true ) ) { global $wp_query; $orderby = ‘meta_value_num’; $wp_query->query_vars[‘meta_key’] = ‘_price’; } if ( ‘price’ ===…

Related Posts:

Comment Section:

3 Comments. Leave new

  • I did this:

    add_filter( ‘relevanssi_orderby’, function ( $orderby ) { return ‘relevance’; } );

    And it took down my entire website! Currently on line to tech support to try and restore it. But I politely suggest this instruction for NOT be followed.\

    Jon

    Reply
    • Jon, the tech support will find out there’s a typo in the code. The code itself cannot do harm like that, but a smallest typo – a missing brace, for example – can crash a site.

      Reply
  • After debugging for hours I found you need to make sure your functions.php doesnt have;

    add_filter(‘facetwp_use_search_relevancy’, ‘__return_false’);

    AND

    function [theme_name]_facetwp_alter_sort_options($options, $params) {
    return [];
    }
    add_filter(‘facetwp_sort_options’, ‘ [theme_name]_facetwp_alter_sort_options’, 10, 2);

    Both of these will skip the Relevanssi sorting

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed