Skip to main contentSkip to footer

Relevanssi doesn’t work automatically with the Query Loop block in GeneratePress and GenerateBlocks. Fortunately, the solution is simple: the Query Loop block has a filter hook for adjusting the query parameters, and you can use that filter hook to enable Relevanssi.

Add this to your site:

add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
	if (! is_admin() && ! empty( $query_args['s'] ) ) {
		$query_args['relevanssi'] = true;
	}
	return $query_args;
}, 10, 2 );

Thanks to Ben Knowles.

If you are using V2 Query Block, the correct snippet is this:

add_filter( 'generateblocks_query_wp_query_args', function( $query_args, $attributes ) {
	if (! is_admin() && ! empty( $query_args['s'] ) ) {
		$query_args['relevanssi'] = true;
	}
	return $query_args;
}, 10, 2 );

Source: Generate support.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Genesis
In some cases, Relevanssi requires modifications to the search result template for the search results to work properly (in particular…

Related Posts:

Comment Section:

Leave a Reply

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

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed