When using the render_callback
for acf_register_block_type
in ACF 5.8, the third parameter $is_preview
is boolean true
in the editor and an array containing the block data in the frontend. This means that the result of using if($is_preview){ … }
is always true
, which is unexpected.
I am running into the same issue. In addition, $block['mode']
is equal to 'preview'
on the frontend.
This is happening for me as well, it appears to be when using the Gutenberg plugin as opposed to core Gutenberg. Core does not pass a 3rd variable so $is_preview
would expect to default to false in the ACF render callback, but the Gutenberg plugin passes the full block array as a parameter which ACF’s function currently does not expect. I’m currently checking true === $is_preview
to determine if it’s a preview because ACF explicitly sets it to true when this is the case.
@blakers you are a lifesaver! Thanks for that workaround, that will work great. I need access to the Group block, so until they add it to core Gutenberg I need to use the plugin.
Agreed! Thanks so much for the solution, @blakers