Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

up vote 8 down vote accepted

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

share|improve this answer
    
Worked for me, thanks @patrick! –  mattrepublic Jul 1 '11 at 14:05

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;
}
share|improve this answer
    
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
    
@t31os It seems to work very well. Thanks! –  Simone Carletti Mar 18 '11 at 14:37
    
@t31os thank you :) –  Rilwis Mar 18 '11 at 16:31
    
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

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' );
share|improve this answer
    
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

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);
}
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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