Remove Editor on WP Page Template
If you would like to remove the default page editor on a specific page template, you can use the following code snippet in your wordpress theme’s functions.php file. Modify your page template by changing the $template_file name ie contact.php.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
add_action( 'admin_init', 'hide_editor' ); function hide_editor() { // Get the Post ID. if ( isset ( $_GET['post'] ) ) $post_id = $_GET['post']; else if ( isset ( $_POST['post_ID'] ) ) $post_id = $_POST['post_ID']; if( !isset ( $post_id ) || empty ( $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 == 'contact.php'){ // edit the template name remove_post_type_support('page', 'editor'); } } |