Support

Account

Home Forums Gutenberg InnerBlocks – no + button to add a block

Helping

InnerBlocks – no + button to add a block

  • Am I missing something or misunderstanding something? I can’t see to get a ‘+’ Add Block button to show in the backend when I select the block which has InnerBlocks in it. I’m not seeing the $template content either

    Here is the Register

    acf_register_block_type(array(
    ‘name’ => ‘case-study-block-container’,
    ‘title’ => __(‘Case Study block container’),
    ‘description’ => __(‘Case Study block container’),
    ‘render_callback’ => ‘theme_acf_render_callback’,
    ‘category’ => ‘custom-blocks’,
    ‘icon’ => $block_icon,
    ‘keywords’ => array( ‘BGEN’, ‘case’, ‘study’, ‘block’, ‘container’ ),
    ‘mode’ => ‘edit’,
    ‘supports’ => array(
    ‘mode’ => false,
    ‘anchor’ => true,
    ‘jsx’ => true
    ),
    ‘example’ => array(
    ‘attributes’ => array(
    ‘mode’ => ‘preview’
    )
    )
    ));

    Here is the code for the block

    <?php

    $block_abbr = ‘csbc’;
    $block_id = $block_abbr . ‘-‘ . $block[‘id’];
    if( !empty($block[‘anchor’]) ) {
    $block_id = $block[‘anchor’];
    }
    $block_classes = ‘block block-‘ . $block_abbr . ‘ ‘ . $block_abbr . ‘-‘ . $block[‘id’];
    if( !empty($block[‘className’]) ) {
    $block_classes .= ‘ ‘ . $block[‘className’];
    }

    if ( $is_preview ) {
    echo ‘‘;
    return;
    }

    $allowed_blocks = array( ‘core/heading’, ‘core/paragraph’ );

    $template = array(
    array(‘core/heading’, array(
    ‘level’ => 2,
    ‘content’ => ‘Title Goes Here’,
    )),
    array( ‘core/paragraph’, array(
    ‘content’ => ‘Colorway: Style Code: Release Date: MSRP: ‘,
    ) )
    );

    ?>
    </div>
    </div>
    </div>
    </div>

    <div id=”<?php echo $block_id; ?>” class=”<?php echo $block_classes; ?>”>
    <?php echo ‘<InnerBlocks allowedBlocks=”‘ . esc_attr( wp_json_encode( $allowed_blocks ) ) . ‘” template=”‘ . esc_attr( wp_json_encode( $template ) ) . ‘” />’; ?>
    </div>

    • wggl

    • June 2, 2021 at 2:53 am

    Same issue here…

    Somehow the button magically disappeared. 😀

Viewing 2 posts - 1 through 2 (of 2 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.