0

I'm looking to achieve basically a wrapper for a collection of gutenberg blocks. The idea is that I can apply some ACF fields to the wrapper and then allow gutenberg to do whatever it does for the inner content.

However, I can't add "gutenberg" as one of the fields in a custom ACF block. The closest thing I can get is a WYSIWYG editor, so that won't work.

Has anyone here managed to get something like this working? Either a wrapper, or allowing the gutenberg editor to be nested within a custom block?

1

Shucks, no sooner than the second I desperately resort to asking here, I run into the answer. So for anyone else who just wants a straight answer and not some 45 minute video that never gets to the point...

acf_register_block_type( array(
    'title'         => __( 'Wrapper', 'client_textdomain' ),
    'name'          => 'wrapper',
    'render_template'   => 'partials/blocks/wrapper.php',
    'mode'          => 'preview',
    'supports'      => [
        'jsx'           => true, // this is the line that makes it work
    ]
));

That supports jsx line allows you to assign ACF fields to the wrapper and then the user can gutenberg all they want inside it.

Your custom block's html needs this in it as well:

<InnerBlocks />

That will enable the gutenberg interface when adding your block in the editor.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.