2

I would like to disable the 'Visual' tab so that the 'Text' tab is always used.

Is there a clean way to do this besides just doing something like .wp-switch-editor { display:none!important; }

enter image description here

4 Answers 4

8

I can think of three way you can do this

  1. Log in to the Admin Control Panel and go to:

    Users -> All Users

    Find your username and click on Edit.

    Check "Disable the visual editor when writing"

  2. Add this code in the themes function.php file

    add_filter( 'user_can_richedit' , '__return_false', 50 );
    
  3. Install a plugin like Disable Visual Editor WYSIWYG

4
  • Was looking for a development approach, not a user approach. Adjusting the setting via the control panel would be a user approach, and having to resort to a plugin is never a good solution. Thanks anyway. Commented May 28, 2014 at 21:16
  • 1
    Did you try adding add_filter( 'user_can_richedit' , '__return_false', 50 ); Commented May 28, 2014 at 21:17
  • No, I just went with the other solution. Commented May 28, 2014 at 21:18
  • 3
    The filter approach is the way to go. Good job.
    – Christine Cooper
    Commented Nov 13, 2014 at 21:15
1

You can use this style/script to remove the visual tab. It works for me.

add_filter( 'admin_footer', 'custom_edit_page_js', 99);

function custom_edit_page_js(){ 
echo '  <style type="text/css">
        a#content-tmce, a#content-tmce:hover, #qt_content_fullscreen{
            display:none;
        }
        </style>';
echo '  <script type="text/javascript">
        jQuery(document).ready(function(){
            jQuery("#content-tmce").attr("onclick", null);
        });
        </script>'; 
}
1
  • This is a very bad solution. The Editor that shows initially will depend on what the user was last using. So if the user was using a visual editor on a different part of the site then comes to this page they will see the visual editor but just not the tab to select it. It would still require them to click the text tab to see the plain text version by which time the visual editor will have messed up the code.
    – David
    Commented Sep 1, 2021 at 10:31
1

The best way to turn off WordPress TinyMCE rich editor (which will disable the Visual tab).

Add this piece of code to your functions.php file.

add_filter('user_can_richedit', '__return_false');
0

I've done it the same way just adding the GET page ID to target only certain pages:

add_filter( 'admin_footer', 'removes_editor_visual_tab', 99 );

function removes_editor_visual_tab()
{
    $post_id = $_GET['post'];
    if($post_id == 1434){
    ?>
        <style type="text/css">
        a#content-tmce, a#content-tmce:hover {
            display:none;
        }
        </style>
        <script type="text/javascript">
            jQuery(document).ready(function() {
                document.getElementById("content-tmce").onclick = 'none';
            });
        </script>
    <?php
    }
}

Your Answer

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

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