Disable Editor functionality

This page is dedicated to the many ways you can disable specific functionality in the Post Editor and Site Editor that are not covered in other areas of the curation documentation.

Restrict block options

There might be times when you don’t want access to a block at all to be available for users. To control what’s available in the inserter, you can take two approaches: an allow list that disables all blocks except those on the list or a deny list that unregisters specific blocks.

Disable the Pattern Directory

To fully remove patterns bundled with WordPress core from being accessed in the Inserter, the following can be added to your functions.php file:

function example_theme_support() {
    remove_theme_support( 'core-block-patterns' );
add_action( 'after_setup_theme', 'example_theme_support' );

Disable block variations

Some Core blocks are actually block variations. A great example is the Row and Stack blocks, which are actually variations of the Group block. If you want to disable these “blocks”, you actually need to disable the respective variations.

Block variations are registered using JavaScript and need to be disabled with JavaScript. The code below will disable the Row variation.

wp.domReady( () => {
    wp.blocks.unregisterBlockVariation( 'core/group', 'group-row' );

Assuming the code was placed in a disable-variations.js file located in the root of your theme folder, you can enqueue this file in the theme’s functions.php using the code below.

function example_disable_variations_script() {
        get_template_directory_uri() . '/disable-variations.js',
        array( 'wp-dom-ready' ),
        wp_get_theme()->get( 'Version' ),
add_action( 'enqueue_block_editor_assets', 'example_disable_variations_script' );

Disable block styles

There are a few Core blocks that include their own block styles. An example is the Image block, which includes a block style for rounded images called “Rounded”. You many not want your users to round images, or you might prefer to use the border-radius control instead of the block style. Either way, it’s easy to disable any unwanted block styles.

Unlike block variations, you can register styles in either JavaScript or PHP. If a style was registered in JavaScript, it must be disabled with JavaScript. If registered using PHP, the style can be disabled with either. All Core block styles are registered in JavaScript.

So, you would use the following code to disable the “Rounded” block style for the Image block.

wp.domReady( () => {
    wp.blocks.unregisterBlockStyle( 'core/image', 'rounded' );

This JavaScript should be enqueued much like the block variation example above. Refer to the block styles documentation for how to register and unregister styles using PHP.

Disable access to the Template Editor

Whether you’re using theme.json in a Classic or Block theme, you can add the following to your functions.php file to remove access to the Template Editor that is available when editing posts or pages:

function example_theme_support() {
    remove_theme_support( 'block-templates');
add_action( 'after_setup_theme', 'example_theme_support' );

This prevents both the ability to create new block templates or edit them from within the Post Editor.

Disable access to the Code Editor

The Code Editor allows you to view the underlying block markup for a page or post. While this view is handy for experienced users, you can inadvertently break block markup by editing content. Add the following to your functions.php file to restrict access.

function example_restrict_code_editor_access( $settings, $context ) {
    $settings[ 'codeEditingEnabled' ] = false;

    return $settings;
add_filter( 'block_editor_settings_all', 'example_restrict_code_editor_access', 10, 2 );

This code prevents all users from accessing the Code Editor. You could also add capability checks to disable access for specific users.

Disable formatting options for RichText blocks

Blocks that support RichText come with the default formatting options provided by WordPress.

Formatting options need to be disabled with JavaScript using unregisterFormatType. The code below will globally disable the Inline Image, Language, Keyboard Input, Subscript, and Superscript options.

wp.domReady( () => {
    wp.richText.unregisterFormatType( 'core/image' );
    wp.richText.unregisterFormatType( 'core/language' );
    wp.richText.unregisterFormatType( 'core/keyboard' );
    wp.richText.unregisterFormatType( 'core/subscript' );
    wp.richText.unregisterFormatType( 'core/superscript' );

This JavaScript should be enqueued much like the block variation example above.