Support » Developing with WordPress » Using render_block to modify the core blocks not render in editor

  • rose18



    I am using the ‘render_block’ filter to modify the core blocks. The added div container it showing up on the front-end, but it’s not rendering in the editor.
    Example (Wrap heading tags in a div):

    function wporg_block_wrapper( $block_content, $block ) {
    	if ( $block['blockName'] === 'core/heading' ) {
    		$content = '<div class="wp-block-heading modified_block">';
    		$content .= $block_content;
    		$content .= '</div>';
    		return $content;
    	return $block_content;
    add_filter( 'render_block', 'wporg_block_wrapper', 10, 2 );

    I see

    <div class="wp-block-heading modified_block">

    in the front-end, however, this is not showing in the editor.

    Is there a way to make it render in both the front-end and the editor?


  • You must be logged in to reply to this topic.