I am working on a site that has an ACF block called a section. It is a simple wrapper with some container html markup and an InnerBlocks element.
I can add an instance of it and inner blocks and all displays correctly. If I add another instance and inner blocks, it looks perfect on the backend. However, when it renders on the front end, the same code from the first instance is rendered twice (same block id, same inner blocks, etc.) If I add additional section blocks, they all show the same inner blocks as the first.
I have run into this issue as well. I’ve been trying to recreate it with a stripped down simple innerblocks test but have been having trouble getting it to reliably trigger.
It seems to have something to do with the block IDs that are being generated by ACF. When copying a block, it copies the ID and does not generate a new one until certain conditions are met (usually altering custom fields).
This code seemed to resolve the issue for me, although I’d like to see a fix in ACF proper.
add_filter( ‘acf/pre_save_block’, function( $attributes ) {
if ( empty( $attributes[‘id’] ) ) {
$attributes[‘id’] = ‘block_’ . uniqid();
}
return $attributes;
}, 10, 1 );