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.
Opens WPIDE on
Code
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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.