Created
August 4, 2016 15:24
-
-
Save dbridgman/8e92f642b05e970b2087e3f2d3e0e0de to your computer and use it in GitHub Desktop.
Hide Default Wordpress Editor Depending On Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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