Since WordPress 6.0, you can define how content inside a group block is aligned. Besides the default, which does nothing, you can also display the content inline in a row or stack it. Together with the new layout options you can then justify the content and set its orientation based on your desires.

If you don’t want to use that feature, you can disable it. It’s basically both a block variation of the group block.

So you need to load a JavaScript file, that is executed once the DOM is ready to unregister these block variations:

wp.domReady( () => { wp.blocks.unregisterBlockVariation( 'core/group', 'group' ); wp.blocks.unregisterBlockVariation( 'core/group', 'group-row' ); wp.blocks.unregisterBlockVariation( 'core/group', 'group-stack' ); } );
Code language: JavaScript (javascript)

Since the first one, group, is the default, you could let it registered. But since the button to select this block variation still shows up, I think it’s better to have it unregistered.

Group block variations with variations
Group block variations before unregister variations
Group block variations without variations
Group block variations after unregister variations

Let’s name the JavaScript file unregister-group-block-variations.js and place it inside your theme’s directory. Then open up your theme’s functions.php and add the following code to enqueue the JavaScript file:

/** * Enqueue editor assets. */ function my_editor_assets() { wp_enqueue_script( 'my-unregister-block-group-variations', get_template_directory_uri() . '/unregister-group-block-variations.js', [ 'wp-blocks', 'wp-editor' ], filemtime( get_template_directory() . '/unregister-group-block-variations.js' ), false ); } add_action( 'enqueue_block_editor_assets', 'my_editor_assets' );
Code language: PHP (php)

Leave a Reply

Your email address will not be published.