Return to Snippet

Revision: 53719
at December 1, 2011 21:56 by f6design


Initial Code
/**
 * 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 == 'contact.php'){ // edit the template name
    	remove_post_type_support('page', 'editor');
    }
}

Initial URL

                                

Initial Description
When adding a meta box to a 'page' in Wordpress (as opposed to a post, or custom post type), you might want to disable the default editor.  Use this snippet in your theme's functions.php file to disable the editor for a specific page template.

Initial Title
Wordpress: Disable the content editor for a specific page template

Initial Tags
wordpress

Initial Language
PHP