0

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 ?

1
  • Pages are posts, they are posts of type 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
    Feb 4, 2015 at 12:21

1 Answer 1

4

Found 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' );
    }
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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