Disable WYSIWYG editor only when creating a page

I read several articles about configuring the WordPress editor. For example, this snippet shows how to permanently set the editor to HTML or WYSIWYG for all contents.

I’m wondering if it’s possible to disable the WYSIWYG only when the user is creating a page, leaving it enabled for any other WordPress content type.

Related posts

Leave a Reply

4 comments

  1. The best way to do this is by adding ‘user_can_richedit’ filter, like so:

    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;
    }
    

    Hope it’s useful 😉

  2. Try this:

    add_filter( 'wp_default_editor', 'rw_default_editor' );
    function rw_default_editor( $type ) {
        global $post_type;
        if('page' == $post_type) 
            return 'html';
        return $type;
    }
    
  3. Do it like this in your functions.php file:

    function remove_post_type_support_for_pages() 
    {
        // UNCOMMENT if you want to remove some stuff
        // Replace 'page' with 'post' or a custom post/content type
        # remove_post_type_support( 'page', 'title' );
        remove_post_type_support( 'page', 'editor' );
        # remove_post_type_support( 'page', 'thumbnail' );
        # remove_post_type_support( 'page', 'page-attributes' );
        # remove_post_type_support( 'page', 'excerpt' );
    }
    add_action( 'admin_init', 'remove_post_type_support_for_pages' );
    
  4. Add the following to the post.php file inside the wp-admin directory. This code should go just before the function redirect_post() section.

    // disable editor (WSYWIG) for the admin page section
    if($post_type == 'page') 
    {   
      add_filter('user_can_richedit' , create_function('' , 'return false;') , 50);
    }