Posted on

FacetWP

Relevanssi is generally well compatible with FacetWP, which provides advanced filtering and faceting capabilities for the search. There are however some situations where Relevanssi and FacetWP do not work well.

Make sure you are using the Relevanssi integration plugin for FacetWP. It covers most of the problems.

Disabling the FacetWP integration

In some cases, however, it’s necessary to disable the FacetWP integration. This comes to play when you are not using FacetWP for Relevanssi searches. In that case using the Relevanssi integration plugin will break the Relevanssi search, but not using will break the FacetWP search facet.

For this, the solution is easy:

add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
	if ( $query->is_search() && $query->is_main_query() ) {
		$is_main_query = false;
	}

	return $is_main_query;
}, 5, 2 );

This little code snippet (from here) in your theme functions.php will disable the FacetWP Relevanssi integration, and everything should work fine.

Searching for users and taxonomy terms

FacetWP can’t handle the way Relevanssi integrates user profiles and taxonomy terms in the search results. Relevanssi gives them post ID -1, and FacetWP can’t deal with that. If you want to use FacetWP for search and search for users, use the FacetWP user searching method, where FacetWP generates a separate post type for users. That can be searched with Relevanssi.

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 *

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