Add powerful, instant live search to any WordPress website – fast, beautiful, and incredibly easy to use.
Relevanssi Live Ajax Search
What is Relevanssi Live Ajax Search?
Relevanssi Live Ajax Search is a lightweight plugin that adds real-time live search functionality to your website. The plugin is very easy to use: simply install and activate it, and you’re ready to go. It can automatically take over most search forms on your site.
Relevanssi Live Ajax Search does not require Relevanssi – it works perfectly with the default WordPress search. Of course, the results are significantly better when used together with Relevanssi, Relevanssi Premium or Relevanssi Light.

Installing Relevanssi Live Ajax Search
Most of the time, installing Relevanssi Live Ajax Search is very easy. All you need to do is install the plugin and activate it. Live Ajax Search is able to automatically take over most search forms.
Sometimes Live Ajax Search cannot hijack the search form without additional help – especially if you have added the search form manually. In these cases you need to add a few parameters to the search term input field (the one with the name s).
Required parameters:
data-rlvlive="true"– Enables Live Ajax Search on this form.data-rlvconfig="default"– Uses the default configuration (you can specify a custom configuration name here).data-rlvparentel="#rlvlive"– Defines the element where the results should appear. This parameter is optional. If used, you must also add an empty<div id="rlvlive"></div>inside the form (this is recommended for better accessibility).
Basic search form examples
<form role="search" method="get" class="search-form" action="/">
<label>
<span class="screen-reader-text">Search for:</span>
<input type="search" class="search-field" placeholder="Search …" name="s">
</label>
<input type="submit" class="search-submit" value="Search">
</form>
<form role="search" method="get" class="search-form" action="/">
<label>
<span class="screen-reader-text">Search for:</span>
<input type="search" class="search-field" placeholder="Search …" name="s"
data-rlvlive="true" data-rlvparentel="#rlvlive" data-rlvconfig="default">
</label>
<input type="submit" class="search-submit" value="Search">
<div id="rlvlive"></div>
</form>
Advanced Features & Customization
The Live Ajax Search plugin uses templates to display the search results. Using templates makes it very easy to override the default output from your theme if you want to customize the appearance.
You can find the default templates in the templates directory of the plugin. To override a template, create a folder called relevanssi-live-ajax-search inside your theme directory and copy the desired template file there. Live Ajax Search will then automatically use your version of the template.
There are two templates: search-results.php (default) and search-results-query.php (used for the alternate WP_Query mode, which is more compatible with third-party plugins).
Live Ajax Search adds two sets of styles to your site. The first set is the baseline CSS that determines the position of the search results. To remove these styles, use the following filter hook:
add_filter( 'relevanssi_live_search_base_styles', '__return_false' );
The second set is the main stylesheet, enqueued as relevanssi-live-search. To disable it completely, use:
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_style( 'relevanssi-live-search' );
}, 99 );
Since version 2.0, Live Ajax Search uses a CSS-based spinner. To change its colour, add the following CSS to your theme:
.rlv-has-spinner {
border-color: #19892c;
border-right-color: transparent;
}
.rlv-has-spinner::after {
background-color: #19892c;
}
Relevanssi Live Ajax Search provides many useful filter hooks for developers:
relevanssi_live_search_add_result_div(boolean) – Controls whether an extra resultsdivis added inside the search form.relevanssi_live_search_alter_results(array) – Modify the search results before they are displayed.relevanssi_live_search_base_styles(boolean) – Disable the base CSS styles.relevanssi_live_search_configs(array) – Filter the available configurations for different search forms.relevanssi_live_search_get_search_form_config(string) – Choose which configuration set is used (default: “default”).relevanssi_live_search_get_template_part(array, string, string) – Filter the templates used to display the results.relevanssi_live_search_hijack_get_search_form(boolean) – Disable automatic form hijacking.relevanssi_live_search_mode(string) – Switch betweenquery_postsandwp_querymode.relevanssi_live_search_status_location(string) – Control where the “X posts found” status note appears.relevanssi_live_search_posts_per_page(int) – Modify the default number of results (default: 7).relevanssi_live_search_query_args(array) – Modify the query arguments passed to the search.relevanssi_live_search_results_template(bool|string) – Filter the location of the template file.relevanssi_live_search_template_dir(string) – Change the name of the template directory.relevanssi_live_search_before_result,relevanssi_live_search_before_result_link,relevanssi_live_search_before_result_title,relevanssi_live_search_after_result_title,relevanssi_live_search_after_result_linkandrelevanssi_live_search_after_result(string) – Inject content in various parts of the template without editing the template file.relevanssi_live_search_result_arrow(string) – Change the “»” after the post title.
Modifying the Search Results
If you are using Relevanssi to power the live search, all Relevanssi filters will also apply to the live results. If you want to create a filter on relevanssi_modify_wp_query that only affects the live search (or only the normal search), you can check for the $_REQUEST['action'] parameter, which is set to relevanssi_live_search during a live search.
Plugin and Theme Compatibility
Relevanssi
With Relevanssi, Live Ajax Search shows drafts and pending posts in the search results. This will be fixed in a future Relevanssi version. In the meantime, you can add the following code to fix the issue:
add_filter( 'relevanssi_live_search_query_args', function ( $args ) {
$args['post_status'] = 'publish,inherit'; // or just 'publish' if you don't need attachments
return $args;
} );
WPML
Relevanssi Live Ajax Search, Relevanssi and WPML currently do not work well together. The search returns no results even though Relevanssi finds the correct posts. This only happens in the default query_posts mode. Use the WP_Query mode instead:
add_filter( 'relevanssi_live_search_mode', function() { return 'wp_query'; } );
Polylang
Searches made with Relevanssi Live Ajax Search do not always respect the language parameters from Polylang. You can explicitly pass the current language using the relevanssi_live_search_query_args filter hook or by adding it to the search form via the get_search_form filter.
Astra and Divi
The default settings of Relevanssi Live Ajax Search do not work perfectly with Astra and Divi. The easiest solution is:
add_filter( 'relevanssi_live_search_add_result_div', '__return_false' );
Storefront
Storefront also requires the same filter as Astra and Divi:
add_filter( 'relevanssi_live_search_add_result_div', '__return_false' );
Elementor
To make the Elementor Search Form widget work with Live Ajax Search, add this code:
add_action( 'elementor_pro/search/before_input', function( $module ) {
$module->add_render_attribute( 'input', 'data-rlvlive', 'true' );
} );
Header search doesn’t get results when the page is scrolled down
Some header formats cause the live search to stop working when the user scrolls down the page. To fix this, set the static_offset parameter to false:
add_filter( 'relevanssi_live_search_configs', function( $configs ) {
$configs['default']['results']['static_offset'] = false;
return $configs;
} );
SearchWP Live Ajax Search is copyright 2014–2020 by SearchWP, LLC.
Questions? Issues?
The official support for the plugin is available in the WordPress.org support forums.
If you are a Relevanssi Premium user, you can also use the dedicated Premium support.
The plugin is also available on GitHub. The issue tracker is an excellent place to post technical questions and suggestions.