Search Improvements

Use Relevanssi with Elementor

  1. Install Relevanssi free plugin

2. Add the Custom Function:

First, you need to add the following PHP function to your site (e.g., through a child theme’s functions.php or a custom plugin):  PHP code at end

This function tells Elementor to use Relevanssi's search functionality when a specific query ID is used.
3. Configure the Elementor Search Widget:
  • Add a Search Widget:
    Add the Search widget to your page, template, or archive (e.g., a Header Template).
  • Enable Live Results:
    In the widget’s Content tab, locate the “Results” section and set “Live Results” to “Show”.
  • Select a Loop Item:
    If you’re using a Loop Grid, select your Loop Item template.
  • Set Query ID:

    Go to the “Query” section and enter my_relevanssi_results (or the name of your custom function) in the “Query ID” field. 

     
3. (Optional) Apply to Search Results Archive:
If you’re using a Search Results Archive page (created with a Loop Grid), you can apply the same custom query filter to it as well. This will ensure that the search results appear in the same order on both the live search results and the archive page. 
				
					function my_relevanssi_results( $query ) {
  $query->set( 'relevanssi', true );
  $query->set( 'orderby', 'relevance' );
}
add_action( 'elementor/query/my_relevanssi_results', 'my_relevanssi_results' );