Posted on


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.

Leave a Reply

Are you a Relevanssi Premium customer looking for support? Please use the Premium support form.

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