Last active
September 24, 2016 23:36
-
-
Save billerickson/1321431 to your computer and use it in GitHub Desktop.
Hide Editor on Specific Template Page
This file contains hidden or 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
<?php | |
/** | |
* Hide Editor | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/code/hide-editor-on-specific-page-template/ | |
*/ | |
function be_hide_editor() { | |
// Get the Post ID | |
$post_id = false; | |
if( isset( $_GET['post'] ) ) | |
$post_id = $_GET['post']; | |
elseif( isset( $_POST['post_ID'] ) ) | |
$post_id = $_POST['post_ID']; | |
$post_id = intval( $post_id ); | |
if( ! $post_id ) | |
return; | |
$current_template = get_page_template_slug( $post_id ); | |
$exclude_on = array( 'group-classes.php', 'trainers.php' ); | |
if( in_array( $current_template, $exclude_on ) ) | |
wp_enqueue_style( 'hide-editor', get_stylesheet_directory_uri() . '/css/hide-editor.css' ); | |
} | |
add_action( 'admin_enqueue_scripts', 'be_hide_editor' ); |
This file contains hidden or 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
#postdivrich{display: none;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@billerickson I think this can be improved. Instead of using wp_enqueue_style and css to hide the editor you can use
remove_post_type_support. You'll just have to change the action from admin_enqueue_scripts to admin_init.