Inspiration For Creative Minds
Home » Labs » Disable WordPress Content Editor for Specific Template  

Filed under Labs

Here is a pretty function which will help you to disable the WordPress Content Editor for a specific page Template. Just copy and paste the bellow function on your WordPress themes function.php, it will work fine. Don’t forgot to edit “templatename.php” in below function with your file name.

<?php
/**
 
 *Function to  Disable WordPress Content Editor for Specific Template
 
 *
 
 */
 
add_action( 'admin_init', 'disable_wp_editor' );
 
 
 
function disable_wp_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 == 'templatename.php'){ // rename this with your template name
 
    	remove_post_type_support('page', 'editor');
 
    }
 
}
?>
It's only fair to share...Share on Google+Tweet about this on TwitterShare on Facebook
Labs

Posts you may like: