The answer given to a previous and identical question is unfortunately not working on my WP install.

I'm using a version of the function recommended there.

function nim_hide_editor() {
    $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
    $template = get_post_meta( $post_ID , '_wp_page_template', true );

    if($template == 'portfolio.php'){
        /*echo "<style>#postdivrich{display:none;}</style>";*/
        remove_post_type_support( 'page', 'editor' );
add_action('admin_init', 'nim_hide_editor');

I've included the commented-out line to show that I tried the technique of echoing the style tag mentioned in the alternate answer, and neither of them worked when selecting by page template. However...

Two things seem incongruous:

  • I've looked in my SQL database via CPanel and "portfolio.php" is indeed the value stored in post_meta for the pages i'm trying to use this on.

  • Selecting the page by $post_ID, and using remove_post_type_support, works.

        if($post_ID == '13'){
        remove_post_type_support( 'page', 'editor' );

I'm going a bit crazy - it seems like I've triple-checked everything. Obviously I could hide that editor with an array of post_ID's that use that template, but that won't work for future pages that use that template.

  • Ach! Maybe it's that the auto-ID generated by auto-draft messing up $GET_['post'] ?
    – nimmolo
    Feb 28 '13 at 23:17

The following works for me, testing with TwentyTwelve.

Using load-{$pagenow} instead of admin_init avoids the checking for the global $pagenow. See comments for further info:

// Run only when editing a page
// For new pages load-page-new.php should be used
// See: http://core.trac.wordpress.org/browser/tags/3.5.1/wp-admin/admin.php#L217
add_action( 'load-page.php', 'hide_editor_wpse_88886' );

function hide_editor_wpse_88886() 
    // Not really necessary, but just in case
    if( !isset( $_GET['post'] ) )

    $template = get_post_meta( $_GET['post'] , '_wp_page_template', true );

    if( 'page-templates/front-page.php' == $template )
        remove_post_type_support( 'page', 'editor' );
  • Hi brasofilo - I can't vote your answer up because i don't have enough rep. But that worked for me - i didn't look that deep inside of admin.php!!!!
    – nimmolo
    Mar 15 '13 at 17:58
  • this seems to target a more precise hook at the moment of page admin load, have i understood that right?
    – nimmolo
    Mar 15 '13 at 18:05
  • Yes, correct, it only fires when /wp-admin/post.php is showing a page post type.
    – brasofilo
    Mar 15 '13 at 18:22

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.