apply_filters( 'render_block', string $block_content , array $block )
Filters the content of a single block.
Description Description
Parameters Parameters
- $block_content
-
(string) The block content about to be appended.
- $block
-
(array) The full block, including name and attributes.
Source Source
File: wp-includes/blocks.php
Changelog Changelog
| Version | Description |
|---|---|
| 5.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
To add a div wrapper outside of some blocks (like
core/paragraphorcore/heading), you can add filter torender_block:// functions.php function wporg_block_wrapper( $block_content, $block ) { if ( $block['blockName'] === 'core/paragraph' ) { $content = '<div class="wp-block-paragraph">'; $content .= $block_content; $content .= '</div>'; return $content; } elseif ( $block['blockName'] === 'core/heading' ) { $content = '<div class="wp-block-heading">'; $content .= $block_content; $content .= '</div>'; return $content; } return $block_content; } add_filter( 'render_block', 'wporg_block_wrapper', 10, 2 );Expand full source codeCollapse full source code