apply_filters( 'relevanssi_block_to_render', array $block )

Filters Gutenberg blocks before they are rendered in the indexing.


(array) The Gutenberg block element before it’s rendered.

More information

When Relevanssi indexes Gutenberg content, the post is split into blocks with parse_blocks() and then each block is rendered with render_block(). This filter hook lets you filter each block before it is rendered.

This hook can be used to remove unwanted blocks. To not index a block, just return an empty value from the filter function. Relevanssi will skip empty values. You can also modify the blocks before indexing.

For example, if you don’t want to index any image blocks, you could achieve that with this:

add_filter( 'relevanssi_block_to_render', 'rlv_no_core_image_blocks' );
function rlv_no_core_image_blocks( $block ) {
  if ( 'core/image' === $block['blockName'] ) {
    return null;
  return $block;

This would prevent Relevanssi from indexing any block content that has the name core/image.

To modify the blocks after they are rendered, you can use the relevanssi_rendered_block filter hook which gets the block after render_block().