apply_filters( 'render_block_data', array $parsed_block, array $source_block, WP_Block|null $parent_block )

Filters the block being rendered in render_block() , before it’s processed.


$parsed_block array
The block being rendered.
$source_block array
An un-modified copy of $parsed_block, as it appeared in the source content.
$parent_block WP_Block|null
If this is a nested block, a reference to the parent block.

Top ↑


File: wp-includes/blocks.php. View all references

$parsed_block = apply_filters( 'render_block_data', $parsed_block, $source_block, $parent_block );

Top ↑


Version Description
5.9.0 The $parent_block parameter was added.
5.1.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Khokan Sardar

    Filter post content block and add custom classes for every post content block wrapper dynamically before render on template.

     * Filters the parsed block being rendered in render_block(), before it's processed.
     * @param array  $parsed_block The block being rendered.
     * @return array $parsed_block Modified block.
    function wpdocs_modify_render_block_data( $parsed_block ) {
        // Do check first its Post Content block or not.
        if ( ! empty( $parsed_block['blockName'] ) && 'core/post-content' === $parsed_block['blockName'] ) {
            $block_attributes = $parsed_block['attrs'];
            // Set custom class for post content block.
            $post_content_classe           = 'wpdocs-content-wrap';
            $block_attributes['className'] = $post_content_classe;
            $parsed_block['attrs'] = $block_attributes;
        return $parsed_block;
    add_filter( 'render_block_data', 'wpdocs_modify_render_block_data' );

You must log in before being able to contribute a note or feedback.