advanced custom fields - Wrap Gutenberg blocks both frontendbackend (PHP approach with ACF)

admin2025-06-02  5

I'm currently running ACF 5.8 Beta 4 & WP 5.1 and I'd like to know if it's possible to wrap Gutenberg blocks in a parent div. For example, the following code allows to do precisely that and apply a padding to the whole element:

function wrap_Block( $block_content, $block ) {

    if ( !empty( $block['blockName'] ) ) {

        $output .= '<div style="padding: 50px">';
        $output .= $block_content;
        $output .= '</div>';

        return $output;

    } else return __return_empty_string();

}

add_filter( 'render_block', 'wrap_Block', 10, 2 );

It works perfectly on the frontend, but has no effect on the backend. So... I was wondering if is there anything else I can try and/or if you can point me in the right direction (granted it's possible).

Thanks in advance!

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748799842a313820.html

最新回复(0)