Hide editor on specific page template

This will disable both the Gutenberg block editor and the Classic Editor from specific page templates or IDs. Add your desired templates to $excluded_templates, and any desired IDs to $excluded_ids.

For more information, see Disabling Gutenberg on certain templates.

<?php /** * Disable Editor * * @package EAStarter * @author Bill Erickson * @since 1.0.0 * @license GPL-2.0+ **/ /** * Templates and Page IDs without editor * */ function ea_disable_editor( $id = false ) { $excluded_templates = array( ); $excluded_ids = array( ); if( empty( $id ) ) return false; $id = intval( $id ); $template = get_page_template_slug( $id ); return in_array( $id, $excluded_ids ) || in_array( $template, $excluded_templates ); } /** * Disable Gutenberg by template * */ function ea_disable_gutenberg( $can_edit, $post_type ) { if( ! ( is_admin() && !empty( $_GET['post'] ) ) ) return $can_edit; if( ea_disable_editor( $_GET['post'] ) ) $can_edit = false; return $can_edit; } add_filter( 'gutenberg_can_edit_post_type', 'ea_disable_gutenberg', 10, 2 ); add_filter( 'use_block_editor_for_post_type', 'ea_disable_gutenberg', 10, 2 ); /** * Disable Classic Editor by template * */ function ea_disable_classic_editor() { $screen = get_current_screen(); if( 'page' !== $screen->id || ! isset( $_GET['post']) ) return; if( ea_disable_editor( $_GET['post'] ) ) { remove_post_type_support( 'page', 'editor' ); } } add_action( 'admin_head', 'ea_disable_classic_editor' );

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk