render_block_(name) filter-hookWP 5.7.0

Filters the content of a single block.

The dynamic portion of the hook name, $name, refers to the block name, e.g. "core/paragraph".

Usage

add_filter( 'render_block_(name)', 'wp_kama_render_block_name_filter', 10, 3 );

/**
 * Function for `render_block_(name)` filter-hook.
 * 
 * @param string   $block_content The block content.
 * @param array    $block         The full block, including name and attributes.
 * @param WP_Block $instance      The block instance.
 *
 * @return string
 */
function wp_kama_render_block_name_filter( $block_content, $block, $instance ){

	// filter...
	return $block_content;
}
$block_content(string)
The block content.
$block(array)
The full block, including name and attributes.
$instance(WP_Block)
The block instance.

Changelog

Since 5.7.0 Introduced.
Since 5.9.0 The $instance parameter was added.

Where the hook is called

WP_Block::render()
render_block_(name)
wp-includes/class-wp-block.php 306
$block_content = apply_filters( "render_block_{$this->name}", $block_content, $this->parsed_block, $this );

Where the hook is used in WordPress

wp-includes/block-supports/layout.php 488
add_filter( 'render_block_core/group', 'wp_restore_group_inner_container', 10, 2 );
wp-includes/block-supports/layout.php 549
add_filter( 'render_block_core/image', 'wp_restore_image_outer_container', 10, 2 );
wp-includes/blocks/gallery.php 33
add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility' );
wp-includes/blocks/latest-posts.php 245
add_filter( 'render_block_data', 'block_core_latest_posts_migrate_categories' );
wp-includes/blocks/navigation.php 711
add_filter( 'render_block_data', 'block_core_navigation_typographic_presets_backcompatibility' );
wp-includes/default-filters.php 683
add_filter( 'render_block_context', '_block_template_render_without_post_block_context' );