Once Again: How to Remove Option from Gutenberg Editor for Specific Block in theme.json

admin2025-01-07  5

Since WP 5.8 we can define various settings in the theme.json which is much appreciated and really helpful. But there are still some options I cannot find, e.g. how can I remove the layout panel from the core/group block?

In theme.json, I tried (not sure about the layout-key):

{
    // ...
    "settings": {
        // ...
        "blocks": {
            "core/group": {
                "layout": false // or [] or {} <-- no effect
            }
        }
    }
}

or

{
    // ...
    "settings": {
        // ...
        "blocks": {
            "core/group": {
                "layout": {
                    "customLayout": false // <-- no effect
                }
            }
        }
    }
}

The following answers here were quite close:

  • How to remove specific panels in the editor (Gutenberg) when editing a block (via right panel)?
  • How to remove unwanted panels inside InspectorControls from core blocks in Gutenberg
  • Remove border radius setting from the Gutenberg button block?

So my question is

Where can I find a complete list of all the possible settings for core-blocks in theme.json?

Alas, the official twentytwentyone theme does not contain a such file.

Since WP 5.8 we can define various settings in the theme.json which is much appreciated and really helpful. But there are still some options I cannot find, e.g. how can I remove the layout panel from the core/group block?

In theme.json, I tried (not sure about the layout-key):

{
    // ...
    "settings": {
        // ...
        "blocks": {
            "core/group": {
                "layout": false // or [] or {} <-- no effect
            }
        }
    }
}

or

{
    // ...
    "settings": {
        // ...
        "blocks": {
            "core/group": {
                "layout": {
                    "customLayout": false // <-- no effect
                }
            }
        }
    }
}

The following answers here were quite close:

  • How to remove specific panels in the editor (Gutenberg) when editing a block (via right panel)?
  • How to remove unwanted panels inside InspectorControls from core blocks in Gutenberg
  • Remove border radius setting from the Gutenberg button block?

So my question is

Where can I find a complete list of all the possible settings for core-blocks in theme.json?

Alas, the official twentytwentyone theme does not contain a such file.

Share Improve this question asked Sep 14, 2021 at 9:32 urukuruk 6148 silver badges22 bronze badges 1
  • 1 It appears that this currently isn't possible: github.com/WordPress/gutenberg/issues/31980. See also: github.com/WordPress/gutenberg/issues/33374 which suggests that hiding this in the future may be a really bad idea (I still want to hide it). – mrwweb Commented Oct 12, 2021 at 14:52
Add a comment  | 

1 Answer 1

Reset to default 0

This is now hypothetically possible in Wordpress 6.4:

To disable the controls for all blocks, "allowEditing": false should be added to settings.layout, like so:

"settings": {
    "layout": {
        "allowEditing": false
    } 
} 

To disable the controls for individual blocks, add "allowEditing": false in settings.blocks.[block name].layout, thus:

"settings": {
    "blocks": {
        "core/cover": {
            "layout": {
                "allowEditing": false
            }
        }
    } 
} 

However, disabling layout makes the row/stack block variations useless since all the alignment controls disappear along with the content/wide size stuff.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736254891a241.html

最新回复(0)