Nael
4/7/2020 - 8:08 PM

Hide WP Editor for a particular template

function hide_editor() {
    $post_id = $_GET['post'] ?? ( $_POST['post_ID'] ?? false );
    if ( ! isset( $post_id ) ) {
        return;
    }

    $template_file = get_post_meta( $post_id, '_wp_page_template', true );
    
    if ( $template_file === 'page-careers.php' ) {
        remove_post_type_support( 'page', 'editor' );
    }
}
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
    $post_id = $_GET['post'] ?? ( $_POST['post_ID'] ?? false );
    if ( ! isset( $post_id ) ) {
        return;
    }

    $frontpage_id = get_option( 'page_on_front' );
	// Disable content editor and featured image for front page.
	if ( $post_id === $frontpage_id ) {
		remove_post_type_support( 'page', 'editor' );
		remove_post_type_support( 'page', 'thumbnail' );
	}
}
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
    $post_id = $_GET['post'] ?? ( $_POST['post_ID'] ?? false );
    if ( ! isset( $post_id ) ) {
        return;
    }

    $blogpage_id = get_option( 'page_for_posts' );
    // Disable content editor for blog archive page.
    if ( $post_id === $blogpage_id ) {
        remove_post_type_support( 'page', 'editor' );
        remove_post_type_support( 'page', 'thumbnail' );
    }
}
add_action( 'admin_init', 'hide_editor' );