Skip to content

Instantly share code, notes, and snippets.

@alexwcoleman
Created May 18, 2017 17:56
Show Gist options
  • Save alexwcoleman/6d4cdfe318641d56eab318bace4c2bf9 to your computer and use it in GitHub Desktop.
Save alexwcoleman/6d4cdfe318641d56eab318bace4c2bf9 to your computer and use it in GitHub Desktop.
Remove the WordPress text editor on pages.
/**
* Hide editor on specific pages.
*
*/
// admin_init fires too late (I think...), so admin_head it is
add_action( 'admin_head', 'hide_text_editor' );
function hide_text_editor() {
$post_id = get_the_ID();
// some admin pages have no ID. Bugger off if there isn't an ID.
if( !isset( $post_id ) ) return;
// Hide the editor on the page titled 'Home'
// You could also do this for IDs.
$pagename = get_the_title($post_id);
if($pagename == 'Home'){
remove_post_type_support('page', 'editor');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment