Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dbridgman/8e92f642b05e970b2087e3f2d3e0e0de to your computer and use it in GitHub Desktop.
Save dbridgman/8e92f642b05e970b2087e3f2d3e0e0de to your computer and use it in GitHub Desktop.
Hide Default Wordpress Editor Depending On Template
/**
* Hide editor for specific 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 == 'landing-page.php'){ // edit the template name
remove_post_type_support('page', 'editor');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment