Home Forums Gutenberg ACF block in blocks template does not respect initial alignment setting


ACF block in blocks template does not respect initial alignment setting

    • macemmek

    • February 15, 2019 at 11:51 pm

    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.


    • macemmek

    • February 16, 2019 at 12:16 am

    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.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.