1

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.