I am working on a WordPress site with ACF Pro (the latest) and have an interesting situation. I need to programmatically insert a Gutenberg block into the WordPress editor with some populated ACF field values.
The following will insert the block for me with no problem:
wp.data.dispatch('core/block-editor').insertBlock(
wp.blocks.createBlock('acf/carousel'), 0
);
Inside my block fields, I have the following:
– A repeater called carousel_media
– The repeater contains an image field called carousel_media_item
(it’s an ACF image field)
Is there a way I can populate the Gutenberg block using ACF? I did some extensive Googling, and maybe I was searching for the wrong things, but I can’t populate the fields beyond inserting the block.
Thank you for reading.