Allow users to filter content by keyword(s).


Available options

Name Description
Search engine Which search engine to use (extra engines appear if SearchWP or our Relevanssi integration add-on is installed)
Placeholder text The default text that appears within the search input
Auto refresh Whether to automatically refresh the results while typing

What gets searched?

By default, search facets use WP core search, which is limited to the post title, excerpt, and body.

If you need more flexibility, we integrate with both SearchWP and Relevanssi. Both plugins let you search other data (custom fields, taxonomy terms, PDF contents, etc) too. After installing, new choices will appear in the facet’s Search engine setting.

Result limits

By default, a search facet returns a maximum of 200 results. Override via the following hook:

add_filter( 'facetwp_search_query_args', function( $search_args, $params ) {
    $search_args['posts_per_page'] = -1;
    return $search_args;
}, 10, 2 );

Including draft posts

Similar to the previous example, you can force drafts to appear in search results via the following hook:

add_filter( 'facetwp_search_query_args', function( $search_args, $params ) {
    $search_args['post_status'] = [ 'publish', 'draft' ];
    return $search_args;
}, 10, 2 );

Relevancy sort

With a search facet is in use, the results are automatically ordered by relevancy. To disable this feature, add the following code:

add_filter( 'facetwp_use_search_relevancy', '__return_false' );

See also