2

Can somebody please explain how I can disable the Layout block setting in the Group Block? I have been spending countless hours trying to disable unnecessary interface elements for our client's sites but cannot seem to wrap my head around the methodology necessary to fully customize the admin experience like we used to pre-Gutenberg.

I do not want to disable the width ability of all of the blocks, but I just don't want it for the group block. You can see what panel I'm referring to at https://wordpress.org/support/article/group-block/.

Layout Panel

2
  • this is probably possible using theme.json to lock it to a specific value or limit the values developer.wordpress.org/block-editor/how-to-guides/themes/…. Do you mean alignment though? The article you linked to refers to layout but there is no specific layout button, the closest is alignment for full width/etc
    – Tom J Nowell
    Commented Mar 15, 2022 at 15:17
  • @TomJNowell I added a screen capture for more clarity. I don't see anything in the theme.json that will disable this layout panel within an individual block.
    – Eric K
    Commented Mar 15, 2022 at 17:46

1 Answer 1

1

I was able to do this with a javascript file loaded in the admin.

// functions.php

// Adjustments to block editor (aka Gutenberg)
add_action('enqueue_block_editor_assets', function () {
    wp_enqueue_script(
        'block-editor-adjustments',
        get_stylesheet_directory_uri() . '/js/block-editor-adjustments.js',
        array('wp-blocks', 'wp-dom-ready', 'wp-edit-post'),
    );
});

// block-editor-adjustments.js

wp.hooks.addFilter(
    "blocks.registerBlockType",
    "mno/block-features",
    customizeBlockFeatures
);

function customizeBlockFeatures(settings, name) {
    // Disable layout options for group blocks
    if (name === "core/group") {
        settings.supports.layout = false;
    }

    return settings;
}

You can use this filter to customize other parts of each block's settings UI. But not every setting is as easy to hide or change as this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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