seantrant
7/15/2016 - 4:43 PM

Hide default editor for specific page templates & post types

Hide default editor for specific page templates & post types

//remove default wisiwig for certain page templates

add_action( 'admin_init', 'hide_editor' );
 
function hide_editor() {
	// Get the Post ID.
	$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
	if( !isset( $post_id ) ) return;
 
	// Get the name of the Page Template file.
	$template_file = get_post_meta($post_id, '_wp_page_template', true);
 
    if($template_file == 'contact.php'){ // edit the template name
    	remove_post_type_support('page', 'editor');
    }
}

//remove default wisiwig for custom post pages

add_action('init', 'init_remove_support',100);
function init_remove_support(){
    $post_type = 'kitchen';
    remove_post_type_support( $post_type, 'editor');
}