I added support for align-wide to my theme, but I don't know how to disable this feature for some existing blocks.

I check Gutenberg documentation but I can't find solution.

add_theme_support( 'align-wide' );

Are you referring to blocks you've built yourself or existing blocks?

If you are building your own blocks you can do something like this:

<BlockControls key="controls"> <BlockAlignmentToolbar value={ align } onChange={ ( align ) => setAttributes( { align } ) } controls={ [ 'wide', 'full' ] } /> </BlockControls>

Make sure you include the components:

const { BlockControls, BlockAlignmentToolbar } = wp.editor;

If you are looking to limit the Alignment of existing blocks, then I'm not sure if that is possible at the moment.

  • Thanks for your answer. I must disable alignment of some existing blocks. Sorry, my mistake. I did not write this. – Michael Oct 22 '18 at 6:29
  • You could overwrite the CSS for just those blocks? For example: .wp-block-cover-image.alignwide { /* your custom CSS here */ } – Danny Cooper Oct 22 '18 at 9:21
  • This is good method but when the design is still this same then the options (align-wide, align-full) are unnecessary. – Michael Oct 22 '18 at 10:10

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.