Skip to content

Instantly share code, notes, and snippets.

@cramdesign
Forked from ramseyp/hide-editor.php
Last active August 1, 2016 21:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cramdesign/b8bf8c40810305bcd8bd to your computer and use it in GitHub Desktop.
Save cramdesign/b8bf8c40810305bcd8bd to your computer and use it in GitHub Desktop.
<?php
/**
* Hide editor on specific pages.
*
*/
function hide_editor() {
global $pagenow;
if( !( 'post.php' == $pagenow ) ) return;
global $post;
// Get the Post ID.
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
if( !isset( $post_id ) ) return;
// Hide the editor on the page titled 'Homepage'
$homepgname = get_the_title($post_id);
if($homepgname == 'Homepage'){
remove_post_type_support('page', 'editor');
}
// Hide the editor on a page with a specific page template
// Get the name of the Page Template file.
$template_file = get_post_meta($post_id, '_wp_page_template', true);
if($template_file == 'my-page-template.php'){ // the filename of the page template
remove_post_type_support('page', 'editor');
}
}
add_action( 'admin_head', 'hide_editor' );
@cramdesign
Copy link
Author

This is nearly identical to the original but I added the change suggested in the comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment