I'm trying (and failing - despite the numerous previous posts by others) to more easily/reliably remove the content editor from this page.

I can remove it using the page-ID:

add_action( 'admin_head', 'hide_editor' );

function hide_editor() {

if( isset( $_GET['post'] ) && $_GET['post'] == '7' ) // '7' is the ID of the page ID.
remove_post_type_support( 'page', 'editor' );

But I'd prefer to remove it according to template used - in this instance, the default 'home.php'.

I've tried various conditionals, variants of 'get_page_template' and 'is_page_template' - none of which work... I suspect because the page uses a default rather than selected template.


WordPress already does this by default, so long as that page doesn't have any existing content. Plus it adds a notice explaining why the editor isn't there.

These are the lines already in WordPress Core:

if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) {
    add_action( 'edit_form_after_title', '_wp_posts_page_notice' );
    remove_post_type_support( $post_type, 'editor' );

Lines 74-76 here: https://github.com/WordPress/WordPress/blob/master/wp-admin/edit-form-advanced.php

  • thanks. I'd wondered why one of my installs did this, but another didn't - I now understand that's because 'if doesn't have any existing content' (for years, to reduce potential misunderstandings, I've added an 'anything here won't display' message to the editor. – glvr Mar 23 '18 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.