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>
I started to have my first attempt with ACF + InnerBlocks and ran into exactly the same problem. Ist there any solution for this?
Same problem here! And same first try with InnerBlocks ^^
I thought I was doing something wrong…
When I insert the block with the editor, I do not see anything… No button to add blocks.
But when I define a template, I see the blocks :/ But still no “add block” button…
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.