Posted on

SearchWP Live Ajax Search

Relevanssi doesn’t ship with a live search feature that would display results as the user types the search terms. There are many other plugins that provide this functionality, but few work with Relevanssi. SearchWP Live Ajax Search is the best one that does. It’s very easy to use, most of the time just install and go (it doesn’t even have a settings page!).

Sometimes the default settings are not good enough, though. One example is searching for attachments. By default, SearchWP Live Ajax Search doesn’t include any attachments in the search results. The post type is not a problem, but the post status is: SearchWP Live Ajax Search includes only posts with the post status publish, while attachments have a status of inherit.

This is easy to fix. Just add the following functions to your theme functions.php file:

add_filter('searchwp_live_search_query_args', 'fix_searchwp_query_args');
function fix_searchwp_query_args($args) {
	return $args;

This will remove the post_status parameter completely from the SearchWP Ajax Live Search, allowing attachments. This will also include private posts in the search results – but only if the user is allowed to see them. Relevanssi will take care of that.

2 comments SearchWP Live Ajax Search

  1. Is it possible to open the SearchWP Live Ajax Search results in a new page? I mean when actually clicking on a live search result link to open in a new window.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.