Skip to main contentSkip to footer

Riode is a WooCommerce theme from ThemeForest. It has a built-in live search that does not automatically use Relevanssi. However, it has a method of switching the search function, which you can use to enable Relevanssi. Add this to your site:

// Return the name of the Relevanssi search function to replace get_posts().
add_filter( 'riode_live_search_function', function() { return 'rlv_riode_search_function'; } );

/**
 * Adjusts parameters to include Relevanssi and runs get_posts().
 *
 * @param string $query The search query. Not used.
 * @param array  $args  The search parameters.
 *
 * @return array An array of posts.
 */
function rlv_riode_search_function( $query, $args ) {
  if ( ! empty( $args['s'] ) ) {
    $args['relevanssi'] = true;
//    $args['post_types'] = 'post,page,product';
//    unset($args['post_type']);
  }
  return get_posts( $args );
}

Riode has WooCommerce product search features where the search term is looked for in the custom fields (for SKU) and product tags. With Relevanssi, that is unnecessary, but it cannot be disabled. Those searches will have an empty search term, so it’s important not to enable Relevanssi there; otherwise, there will be garbage in the search results.

The search is restricted to products. If you want other post types, uncomment the two commented lines in the function and replace 'post,page,product' with a list of post types you want to include in the search.

Your account

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

Search

Popular Resources

WP All Import
By default posts imported with WP All Import do not get indexed by Relevanssi. The importing process does not trigger…

Related Posts:

Currently there are no related posts available.

Comment Section:

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