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

WooCommerce: Hidden products in search

Relevanssi by default shows out-of-stock and excluded from catalogue WooCommerce products in the search results, but hides those set to excluded from search (before 2.2.2 and 4.1.2 the default behaviour was to show all products). It is quite easy to make Relevanssi not display hidden products in the results. The…products from the search. This method leads to much faster indexing times. Add this to your site: add_filter( ‘relevanssi_woocommerce_indexing’, ‘rlv_woocommerce_filter’ ); function rlv_woocommerce_filter( $blocks ) { $blocks[‘outofstock’] = true; $blocks[‘exclude-from-catalog’] = true; $blocks[‘exclude-from-search’] = true; return $blocks; } There’s one key for each product visibility level, set the ones you……), ‘product_visibility’, $post_id ) ) { $block = true; } return $block; } This code will unindex products that are set to be excluded from the catalogue, excluded from search or that are out of stock. If you want to keep out of stock items in the search results, just…

Polylang: Bilingual search
By default, Relevanssi indexes the different language versions of the posts separately. If your site is in French and English,…

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