Home › Forums › Gutenberg › Block content is duplicating on the front end but looks fine in the back end. › Reply To: Block content is duplicating on the front end but looks fine in the back end.
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 );
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.