WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Ach! Maybe it's that the auto-ID generated by auto-draft messing up $GET_['post'] ? – nimmolo Feb 28 '13 at 23:17
up vote 2 down vote accepted

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' );
share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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