Created
October 28, 2013 20:30
-
-
Save ramseyp/7204052 to your computer and use it in GitHub Desktop.
Hide the WordPress editor on specific pages. This example looks for a page's name or a page template. The code goes in your functions.php file.
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
<?php | |
// Hide Editor on Select Pages | |
function s25_hide_editor() { | |
// 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 == 'page-template-sponsors.php'){ // the filename of the page template | |
remove_post_type_support('page', 'editor'); | |
} | |
} | |
add_action( 'admin_init', 's25_hide_editor' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment