Remove main editor from wordpress edit page screen

ugreen picture ugreen · Mar 30, 2010 · Viewed 16.7k times · Source

Anyone know of a way to remove the main editor from the page edit screen? And not just with css. I've added a few other meta boxes with the tinymce and they collide with the main one.

I have a class that removes other meta boxes from the edit screen, but I cant get rid of the main editor this way. I've tried to add 'divpostrich' and 'divpost' to the array in the class (but with no luck):

class removeMetas{
    public function __construct(){
        add_action('do_meta_boxes', array($this, 'removeMetaBoxes'), 10, 3);
    }

    public function removeMetaBoxes($type, $context, $post){
        /**
         * usages
         * remove_meta_box($id, $page, $context)
         * add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default')
         */
        $boxes = array( 'slugdiv', 'postexcerpt', 'passworddiv', 'categorydiv',
                        'tagsdiv', 'trackbacksdiv', 'commentstatusdiv', 'commentsdiv',
                        'authordiv', 'postcustom');

        foreach ($boxes as $box){
            foreach (array('link', 'post', 'page') as $page){
                foreach (array('normal', 'advanced', 'side') as $context){
                    remove_meta_box($box, $type, $context);
                }
            }
        }
    }
}

$removeMetas = new removeMetas();

I have also tried removing the 'divpostrich' with jquery. But cant figure out where to put the js for it to work. When I remove the 'postdivrich' in the browser with firebug - my remaining tinymce fields work perfect.

Any ideas?

Answer

Evan picture Evan · Feb 4, 2013

There is built in WP support for this so you don't have to fiddle directly with the globals and ensure forwards compatibility if they ever change how features are handled. The WP Core code does pretty much the exact same logic as @user622018 answer however

function remove_editor() {
  remove_post_type_support('page', 'editor');
}
add_action('admin_init', 'remove_editor');