# Hide Template Editing in the Post Editor

> Removes the option to switch to and edit the site template from inside the post and page editor, so content editors cannot change the site layout by accident.

- Type: PHP
- Runs: Run everywhere
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: templates, editor, permissions
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/disable-template-editing-from-posts/

## Code

```php
add_filter( 'block_editor_settings_all', function ( $settings, $context ) {
    if ( ! empty( $context->post ) ) {
        $settings['supportsTemplateMode'] = false;
    }

    return $settings;
}, 10, 2 );
```

## Notes

Administrators can still edit templates in the Site Editor.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Hide Template Editing in the Post Editor" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
