Hi. I want to used InnerBlocks on multiple places inside an acf block like so:
<?php
$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>
<div class="col-12 col-md-6">
<InnerBlocks allowedBlocks="<?php echo esc_attr(wp_json_encode($allowed_blocks_right)); ?>" />
</div>
</div>
</div>
</div>
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.
Now create template with lock function for each blocks mentioned above:
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… ^^
If You never did it before the good starting point would be to see InnerBlocks with ACF blocks written by Bill Erickson.
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.