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

Issues with post order plugins
If you’re getting low-quality results and the weight settings are not affecting the results, the first thing to check is…
Integrating Post Views Counter stats
It’s possible to integrate all kinds of external data to Relevanssi weights. Post Views Counter is an analytics plugin that collects stats…
User Access Manager
Relevanssi has a conflict with User Access Manager plugin. Both plugins attach to the same `the_posts` filter hook with the…

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