string $block_content, array $block, WP_Block $instance )
Filters the content of a single block.
The block content.
The full block, including name and attributes.
The block instance.
View all references
$block_content = apply_filters( 'render_block', $block_content, $this->parsed_block, $this );
To add a div wrapper outside of some blocks (like
core/heading), you can add filter to
This doesn’t work anymore I’m afraid as all core blocks have their `blockName` set to null for some obscure reason :( https://github.com/WordPress/WordPress/blob/master/wp-includes/blocks.php#L697 — By petrey —
(array) The full block, including name and attributes.
Good to know that
$block['attrs']do not include attributes declared in block.json with “source” set to “attribute”.
For example, in a block.json :
Here’s a quick/rough example of how you can render any block in any way with this filter. Note that the example uses an attribute called `name_of_attribute_here`. You’ll want to use an actual attribute that belongs to that block.
A quick/easy way to discover what’s available to you is to `print_r( $block );` inside the function, refresh the frontend page where the block sits, and see what’s available in the `attrs`.