I use 5.8.0-beta3 to create Gutenberg blocks in ACF.
I’d like to create block templates for the post types but I cannot set default alignment for an ACF block.
Look at a sample code below:
add_action( 'init', 'add_block_templates_to_posts' );
function add_block_templates_to_posts() {
$post_type_object = get_post_type_object( 'report' );
$post_type_object->template = array(
array( 'acf/header', array() ),
array( 'acf/overview', array( 'align' => 'full' ) ),
array( 'core/image', array( 'align' => 'full' ) ),
array( 'core/paragraph', array( 'className' => 'intro' ) ),
);
}
When adding a new report, the core image block is properly full-aligned but the custom block acf/overview is not (although it supports this kind of alignment and I can set it manually by clicking the icon). The initial state does not follow the above setting.
I know that the staff read this forum, so maybe it will be fixed in the new version.
Thanks!
BTW, I discovered that I can set default alignment at a block type registration level but still not in a template.
acf_register_block_type( array( ..., 'align' => 'full', ... ));
I’m having trouble setting the default alignment as well except I’m unable to set the default alignment at the registration point. Are you able to have a block show up as Full Width by default? I have full-width enabled at the theme level and I’m able to set the width manually by the using the controls after a block has been put on the screen but they do not respect the default ‘align’ option.
I added 'align' => 'full'
property to acf_register_block_type
but when I add new acf block into content, this do not show the align full property but the wide value, until I change some value on any field, the main editor refresh and until then, the 'full'
value is recognized.