Sometimes you don’t need a content editor for the specific page templates. It’s useful for thank you pages and other pages that has a fixed text and may not need any content.
Instructions: Add the following code to the functions.php file of your WordPress theme.
You need to change the template filename in the code. Currently it’s submit.php but you can replace it with any filename.
add_action( 'admin_init', 'hide_editor' ); function hide_editor() { $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; if( !isset( $post_id ) ) return; $template_file = get_post_meta($post_id, '_wp_page_template', true); if($template_file == 'submit.php'){ // edit the template name remove_post_type_support('page', 'editor'); } }
You may also enjoy adding custom CSS for WordPress editor.
It worked for me! Great stuff.
Added it to my snippet collection.
Thank you. It worked for me.
Tks
You just saved me, my friend. Thanks a million!
Just FYI, my admin page initially didn’t load on a server error after putting in the code above. I changed this:
$post_id = $_GET[‘post’] ? $_GET[‘post’] : $_POST[‘post_ID’] ;
if( !isset( $post_id ) ) return;
to this:
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;
…and it fixed the issue.
Thanks again!
-Chris
gracias, muy util
this doesn’t work for me, I get the errors undefined index post and post_ID in the backend
Thanks for this. I’ll have to try it!
Cool glad you like it.