Home › Forums › Bug Reports › acf_register_block default align
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?
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
The topic ‘acf_register_block default align’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.