WordPress Snippets

Disable the WP Editor on Page Templates

<?php
add_action( 'admin_init', 'hide_editor' );
 
function hide_editor() {
	$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;

	if( !isset( $post_id ) ) {
		return;
	}
 
	$template_file = get_post_meta($post_id, '_wp_page_template', true);

	switch ( $template_file ) {

		case 'name_of_page_template_file.php':
			remove_post_type_support('page', 'editor');
	}
}

 

Leave a Reply