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.
The following works for me, testing with TwentyTwelve.
Using
load-{$pagenow}
instead ofadmin_init
avoids the checking for the global$pagenow
. See comments for further info: