Disable WordPress visual editor without losing media upload and insertion support

Disabling the visual text editor in a users settings page or by the following code in your functions.php file may have an unintended consequence.

//hide visual editor
add_filter('user_can_richedit', create_function('', 'return false;'), 50);

While it will remove the visual editor it also removes media upload capabalities (without removing the ‘add media’ button to boot!).

A way to work around this is to make the html editor the default shown and hide the editors tabs.

Add this to your functions.php file.

//make the html editor default
add_filter('wp_default_editor', create_function('', 'return "html";'));

Add this to a css file which loads only in admin.

    display: none;

If you don’t already have a custom css file enqueued for admin add this to your functions.php file.

//add css for all admin areas
function my_admin_theme_style() {
    wp_enqueue_style('m-admin-style', get_template_directory_uri() . '/css/admin.css');

add_action('admin_enqueue_scripts', 'my_admin_theme_style');

And you’re done!

Leave a Reply

Your email address will not be published. Required fields are marked *