Removing Visual Editor On a Specific Page

I been trying to remove Visual Editor from a specific page only. I managed to remove Visual editor from all pages using this code

add_filter( 'user_can_richedit', 'patrick_user_can_richedit');

function patrick_user_can_richedit($c) {
global $post_type;

if ('page' == $post_type)
return false;
return $c;
}

Is there any way I can remove the visual editor from only one page? Im using WordPress

Related posts

Leave a Reply

4 comments

  1. Geez … how many forums are you gonna post this question on? lol … That was the same solution I posted on the .org forums … but …

    I told you the better solution was to not tinker with the core WP files, and just use a plugin like this: Disable WYSIWYG on Specific Pages or Posts

    This way, you’re not tinkering with the core WP files, and when you update your WP, you won’t lose all your changes … so you don’t have to keep a personal changelog handy.

    Remember the rule: “When in doubt, don’t” … if you’re thinking of changing all your php files, and you’re unsure as to whether you should or not, don’t.

  2. This worked for me

    // removes rich text editor for certain pages
    function remove_pages_editor(){
        if(get_the_ID() === 95) {
            remove_post_type_support( 'page', 'editor' );
        } // end if
    } // end remove_pages_editor
    add_action( 'add_meta_boxes', 'remove_pages_editor' );
    
  3. You can use some Plugin to add custom field (Advanced Custom Fields is the best), then use it in the following code:

    add_filter( 'user_can_richedit', 'on_post_user_can_richedit');
    function on_post_user_can_richedit($c) {
        global $post_type;
        $sw_off_visual_editor = get_field('sw_off_visual_editor');
    
        if(!empty($sw_off_visual_editor) && $sw_off_visual_editor[0] == 1)
            return false;
        return $c;
    }
    

    I added custom checkbox, take it from get_field(‘sw_off_visual_editor’);, then test it $sw_off_visual_editor[0] == 1.

  4. To REMOVE only the [Visual] Tab, and force HTML/TEXT, this will work. You can add other page_id to the if command to target other 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
        }
    }