Support

Account

Home Forums Bug Reports acf_register_block default align

Solving

acf_register_block default align

    • sidas

    • April 17, 2019 at 6:28 pm

    Hello everyone, so I want to ask how this default align works for acf_register_block. Because when I add align like this:

    acf_register_block([
    	[name] => block-hero-small-acf 
    	[title] => Hero Small 
    	[description] => Used to create hero with image and list 
    	[category] => formatting 
    	[icon] => format-image 
    	[keywords] => Array ( 
    		[0] => hero 
    		[1] => image 
    	) 
    	[mode] => edit 
    	[render_callback] => sage_blocks_callback 
    	[supports] => Array ( 
    		[align] => false
    	) 
    	[align] => full
    ]);

    You can see [align] => full at the end. THen nothing happens, BE editor still shows as default?

    • JasperV

    • April 30, 2019 at 9:41 pm

    To be able to use full and wide align, you must run a theme that supports it, this requires the theme to set an option and add some CSS.
    Twentynineteen supports this, but if you’re running your own theme you can add support for it yourself. How to do this is written in this article.

    Now about the bit of code you sent, setting 'align' => 'full' should be correct and set the default alignment to full. Maybe try recreating your block to see if it’s set to full then?

  • I’m experiencing this as well. I’m able to set the default alignment if I set up the block as part of a template but the block does not respect the default alignment if it’s added after the fact to a page.

  • When your theme supports wide alignment via add_theme_support('align-wide');, you still have to enable alignment for your block. Replace 'supports' => [ 'align' => false ] with 'supports' => [ 'align' => true ]. Unfortunately, this enables the user to change the alignment, but it does set the default align.

    NB: Using 'supports' => [ 'align' => [ 'full' ] ] is not possible at the moment due to a restriction in Gutenberg.

  • I’m able to set the default alignment if I set up the block as part of a template but the block does not respect the default alignment if it’s added after the fact to a page. MyPrepaidBalance

Viewing 5 posts - 1 through 5 (of 5 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.