How to Hide the WordPress Content Editor on Specific Pages

While developing a website or blog in WordPress it’s usually best practice to provide your client with a backend that makes as much sense possible from an editing standpoint. A situation may arise when you develop a page requiring a large amount of custom fields and sections but don’t end up utilizing the actual WordPress content editor. In our opinion, we feel that in this instance it is best practice to hide the WordPress content editor in order to avoid any potential confusion. In this tutorial we will teach you how to hide the content editor on specific pages via a WordPress function.

Hide the WordPress Content Editor on a Specific Page

In order to hide the WordPress content editor on a specifc page, we will add a PHP filter to the WordPress functions file. Open your functions.php file then copy and paste the code below, you will need to reference the ‘Items to Note’ below in order to adjust the code to work with your specific page title.

PHP

add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
  $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
  if( !isset( $post_id ) ) return;
  $pagetitle = get_the_title($post_id);
  if($pagetitle == 'Your Page Title'){
    remove_post_type_support('page', 'editor');
  }
}

Items to Note:

  • $pagetitle is a specific variable that will grab the title of the page you are on in the dashboard by its unique post ID.
  • The $pagetitle variable is then referenced in the ‘if’ statement; this is where you need to make sure you change ‘Your Page Title’ to the actual page title you are using.
  • The ‘if’ statement is basically saying if the current page title is equal to this title then hide the content editor.
  • If you followed the instructions correctly the content editor will now be hidden from your specific page in the WordPress dashboard.

Hide the WordPress Content Editor on Multiple Pages

In order to hide the WordPress content editor on multiple pages, we will need to slightly modify the PHP filter used above in your functions.php file.

PHP

add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
  $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
  if( !isset( $post_id ) ) return;
  $about = get_the_title($post_id);
  $contact = get_the_title($post_id);
  if($about == 'About' || $contact == 'Contact'){ 
    remove_post_type_support('page', 'editor');
  }
}

Items to Note:

  • You will notice that we are no longer using the variable $pagetitle anymore. You will need to setup specific variables for the pages you would like to hide the content editor on. For purposes of this tutorial we used ‘about’ and ‘contact’.
  • You will then need to add the multiple variables to the ‘if’ statement. Remember to make sure that your specific page titles need to match with what is in the quotes.
  • The ‘if’ statement is now basically saying that if any of the page title variables equal the current page title then hide the content editor.
  • If you followed the instructions correctly the content editor will now be hidden from your specific pages in the WordPress dashboard.

Troubleshooting

If you are having problems getting this tutorial to work please reread the tutorial and try again, if you still cannot get it to work please leave us a comment below and we will respond as soon as possible. Please do not email us with problems regarding this tutorial, only comments will be responded to.