Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove main editor from wordpress edit page screen

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?

like image 254
ugreen Avatar asked Mar 30 '10 11:03

ugreen


People also ask

How do I remove editor from WordPress page?

First, you need to visit Users » Your Profile page in the WordPress admin area. This is where you can edit your user profile in WordPress. Under the visual editor, you need to check the box next to 'Disable visual editor when writing' option. Don't forget to click on the 'Update Profile' button to save your settings.

How do I remove the HTML editor from WordPress?

In contrast to the visual editor in WordPress, you can not disable the HTML editor. WordPress does not provide a user setting or a global option. Also, there is no hook, to disable the HTML tab above the editor when writing posts or pages.

Can WordPress editors edit pages?

Users with the editor user role can edit all posts and pages on your website. Many WordPress sites are structured in a way where editors are usually responsible for content like articles and blog posts.


1 Answers

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');
like image 164
Evan Avatar answered Sep 24 '22 18:09

Evan