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

Voice Search

Elementor search forms to ensure a perfect fit. If you wish to customize the appearance, you can use the following CSS classes in your theme: .relevanssi-voice-search-wrapper: The container around the search input. .relevanssi-mic-button: The actual microphone button. .is-active: A class added to the button while it is “listening.” .is-talking: A…

Envira Gallery
Envira Gallery is a gallery plugin for WordPress. Since it uses a custom post type for the galleries, it works…
Indexing embedded PDFs for the parent post

…$upload_dir = wp_upload_dir(); foreach ( $matches[1] as $pdf ) { $pdf_url = ltrim( str_replace( $upload_dir[‘baseurl’], ”, urldecode( $pdf ) ), ‘/’ ); $pdf_content = $wpdb->get_var( $wpdb->prepare( “SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = ‘_relevanssi_pdf_content’ AND post_id IN ( SELECT post_id FROM $wpdb->postmeta WHERE meta_key = ‘_wp_attached_file’ AND meta_value = %s……SELECT post_id FROM $wpdb->postmeta WHERE meta_key = ‘_wp_attached_file’ AND meta_value = %s )”, $pdf_url ) ); $content .= $pdf_content; } } return $content; } 3D Flipbook 3D Flipbook has the flipbook post ID as the shortcode parameter, and you can find the attachment post ID in the post meta for…meta_key = ‘_wp_attached_file’ AND meta_value = %s )”, $pdf_url ) ); $content .= $pdf_content; } } return $content; } If you use the Gutenberg block, the code is different and uses the relevanssi_block_to_render filter hook: add_filter( ‘relevanssi_block_to_render’, ‘rlv_pdfembedder_content’, 10 ); function rlv_pdfembedder_content( $block ) { if ( $block[‘blockName’] === ‘pdfemb/pdf-embedder-viewer’…

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