WordPress 6.0: Disable layout options
Published: – Leave a comment Last update:
WordPress 6.0 comes with new layout options for certain blocks, e.g. the group block. These options allow to limit the width of its content. Since it’s available by default without explicit opt-in, one might want to disable it. However, there is no builtin option so far to do that.
Since the blocks define whether they support these layout options, you can disable the support by filtering the block type’s metadata and set the support for __experimentalLayout
to false
. You can use the code below and add it to your (child) theme:
/**
* Filter block type metadata to remove unwanted output from the editor.
*
* @see https://github.com/WordPress/gutenberg/issues/31980#issuecomment-1033935746
*
* @param array $metadata Metadata for the currently processed block type.
* @return array Filtered metadata.
*/
function my_filter_block_type_metadata( $metadata ) {
if ( isset( $metadata['supports']['__experimentalLayout'] ) ) {
$metadata['supports']['__experimentalLayout'] = false;
}
return $metadata;
}
add_filter( 'block_type_metadata', 'my_filter_block_type_metadata' );
Code language: PHP (php)
After that, the layout options are disappeared from all blocks that usually have these settings.