Home Forums Gutenberg Gutenberg Parent/Child Blocks


Gutenberg Parent/Child Blocks

    • okadots

    • January 22, 2019 at 9:22 am


    Loving the ACF Gutenberg Beta so far!

    I am using a nested block approach to create a better grid for a boilerplate theme. I have created a block (via a plugin, the WP way – not ACF) called “Row” that will set an outer wrapper for other blocks (have added the <InnerBlocks /> to this block). Using the allowedBlocks parameter, I can specify all of the core blocks that are allowed in my “Row” block. This is all excellent so far…

    As I create new ACF blocks, I don’t want to have to edit the plugin to add the ACF blocks to the plugin because the ACF blocks will differ between my projects. Gutenberg allows for a “parent” to be specified in a new block. This makes it so that the child block will be allowed in the parent block without specifically adding the new block to the list of allowedBlocks.

    My question: is it possible to add a “parent” parameter to the acf_register_block function? Similar to the other parameters like “name”, “title”, etc?

    I realize this is similar to another topic already posted (link below), but not quite. I am creating the wrapper natively via a plugin. I’m just looking for the addition of a parent parameter.

    • okadots

    • January 22, 2019 at 9:34 am

    I have made a change to the ACF plugin to accomplish this – perhaps I need to submit as a Git Issue/PR?

    In any case – in blocks.php in ACF, line 88 validate_block_type – I added an additional parameter to $block array and was successfully able to pass it along via the acf_register_block function.
    'parent' => ''

    • alicam

    • January 22, 2019 at 4:33 pm

    Are you able to share that plugin? I’d love to see it. I’m looking for a lightweight plugin with JUST a row/section/container/wrapper block, as you describe it, and I can’t find one!


    • okadots

    • January 23, 2019 at 5:34 am

    @alicam unfortunately I’m not able to share the plugin at this time (it’s for my job).

    The plugin, at the moment, is just a native Gutenberg block called “Row”. I created it following this tutorial for making a nested block. It’s essentially just a wrapper div with the <InnerBlock> inside of it. Sorry I can’t be more helpful!

    • jrisum

    • November 6, 2019 at 8:27 pm

    Did you ever solve this? I need this feature too! Thanks! <3

    • okadots

    • November 7, 2019 at 4:02 am

    @jrisum no, we never got anywhere with this. Just the plugin code change I mentioned – and we haven’t upgraded the plugin since the beta version.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.