6

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.

11

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

4

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;
}
  • When I create a new page it works, but it doesn't when I edit an existing one. It assumes the post_type is always passed in querystring but this is not true. – Simone Carletti Mar 18 '11 at 13:45
  • 1
    There's a post type global, i've adjusted rilwis's answer to use that instead, give it a shot. – t31os Mar 18 '11 at 14:09
  • I'm sorry, but I replied without performing all the tests. It doesn't seem to disable the editor, but only make the HTML the first choice. Also, if you selected the WYSIWYG (and the preference cookie is set) the cookie wins. – Simone Carletti Mar 20 '11 at 11:43
1

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' );
  • This completely removed the field. I just want to make it a text-area, not remove the field. – Simone Carletti Apr 13 '11 at 9:07
-2

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);
}
  • Core modifications are really not encouraged. A WordPress upgrade will remove this modification of core file post.php. – Ardee Aram Nov 22 '12 at 7:14
  • Second DownVote this answer, while it may work, it is not at all the right way to do it. – rfair404 Nov 11 '14 at 14:36
  • downvoted: never edit core files – user2015 Jun 18 '15 at 1:49

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.