Home Forums Gutenberg Used InnerBlocks multiple in one ACFBlock


Used InnerBlocks multiple in one ACFBlock

  • Hi. I want to used InnerBlocks on multiple places inside an acf block like so:

    $allowed_blocks_left = [''core/list', 'core/button', 'core/image'];
    $allowed_blocks_right = ['core/heading', 'core/paragraph'];
    <div <?php echo $anchor; ?>class="<?php echo esc_attr($class_name); ?>">
        <div class="container">
            <div class="row">
                <div class="col-12 col-md-6">
                    <InnerBlocks allowedBlocks="<?php echo esc_attr(wp_json_encode($allowed_blocks_left)); ?>" />
                <div class="col-12 col-md-6">
                    <InnerBlocks allowedBlocks="<?php echo esc_attr(wp_json_encode($allowed_blocks_right)); ?>" />

    Is this possible? At the moment the content of “InnerBlocks” simply duplicates itself.

  • It’s easy!
    Just change the way You think about the inner blocks as they’ll always have “only one place” to include the inner blocks.
    Is all about making more blocks + limit blocks that You can insert + default block template.

    1. Make a container block with innerblocks and name it like “Two Columns: Layout A”
    2. Make a child block called “Two Columns: Layout A – Left Column”
    3. Make a child block called “Two Columns: Layout A – Right Column”

    Now create template with lock function for each blocks mentioned above:

    • 1. Container – template with allowed only: 2 and 3 (blocks left & right column)
    • 2. Left Col. template with allowed only: ‘core/list’, ‘core/button’, ‘core/image’
    • 3. Right Col. template with allowed only: ‘core/heading’, ‘core/paragraph’

    More to read: resources/acf_register_block_type – look for: allowedBlocks, template & templateLock.

  • Thank you! That helped me alot. Sometimes it can be so simple… ^^

  • Thanks, helped me too

  • Hello! I have the same problem. Can you show the solution?

  • If You never did it before the good starting point would be to see InnerBlocks with ACF blocks written by Bill Erickson.

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

You must be logged in to reply to this topic.