Hide Empty Editor

If you’re using custom metaboxes for all the post’s content, you may want to hide the editor for a cleaner editing experience. But what about the old content that still uses the editor? This code only hides the main editor once it is empty (once the metaboxes are the only sources of content).

<?php
/**
* Hide empty editor on posts
*
*/
function ea_hide_empty_editor() {
$screen = get_current_screen();
if( $screen->id !== 'post' )
return;
$hide = true;
if( isset( $_GET['post'] ) && !empty( get_post( $_GET['post'] )->post_content ) ) {
$hide = false;
}
if( $hide ) {
remove_post_type_support( 'post', 'editor' );
}
}
add_action( 'admin_head', 'ea_hide_empty_editor' );
view raw functions.php hosted with ❤ by GitHub

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