1

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

6

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

  • 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. – davidcondrey May 28 '14 at 21:16
  • 1
    Did you try adding add_filter( 'user_can_richedit' , '__return_false', 50 ); – user3635808 May 28 '14 at 21:17
  • No, I just went with the other solution. – davidcondrey May 28 '14 at 21:18
  • 1
    The filter approach is the way to go. Good job. – Christine Cooper Nov 13 '14 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>'; 
}
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
    }
}
0

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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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