I've found several function examples online that remove the content editor based on the template of the page. The issue I am having is that the content is not a post, but the wordpress generic "page" functionality.
I want to remove the main content editor from all pages - not custom post type, just standard WP page.
I have tried the code below. However I believe the edit on the templat-file
part is incorrect because this is not a post type:
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
// Get the Post ID.
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
if( !isset( $post_id ) ) return;
// Get the name of the Page Template file.
$template_file = get_post_meta($post_id, '_wp_page_template', true);
if($template_file == 'page.php'){
remove_post_type_support('page', 'editor');
}
}
How else can I do this to all pages ?
I've found several function examples online that remove the content editor based on the template of the page. The issue I am having is that the content is not a post, but the wordpress generic "page" functionality.
I want to remove the main content editor from all pages - not custom post type, just standard WP page.
I have tried the code below. However I believe the edit on the templat-file
part is incorrect because this is not a post type:
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
// Get the Post ID.
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
if( !isset( $post_id ) ) return;
// Get the name of the Page Template file.
$template_file = get_post_meta($post_id, '_wp_page_template', true);
if($template_file == 'page.php'){
remove_post_type_support('page', 'editor');
}
}
How else can I do this to all pages ?
Share Improve this question asked Feb 4, 2015 at 12:08 FrancescaFrancesca 3052 gold badges7 silver badges16 bronze badges 1 |1 Answer
Reset to default 4Found the following solution which works to remove the content editor from all "page" content. Just chuck it in the functions.php file
add_action('admin_init', 'remove_textarea');
function remove_textarea() {
remove_post_type_support( 'page', 'editor' );
}
page
, for the most part they're no different to other custom post types, and they're stored the same way in the database – Tom J Nowell ♦ Commented Feb 4, 2015 at 12:21