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.

Trying to remove the WYSIWYG Editor on all post types except the default pages and posts.

Shouldn't this work

// Remove WYSIWYG Editor
function remove_wysiwyg( $hook ) {
    if ( $hook != 'post-new.php' || $hook != 'post.php' )
    add_filter('user_can_richedit', '__return_false');
}
add_action( 'init', 'remove_wysiwyg' );
share|improve this question
    
maybe I misunderstood, do you want to just disable the html editor and leave the text editor? –  Milo Jan 25 '13 at 5:50
    
I'd like to just leave the html editor on custom post types. I edited my post, shouldn't that work? –  ftntravis Jan 25 '13 at 6:00

2 Answers 2

You should look for the post type in the URL or the type of the post itself, and you can be more specific and run the code for only admin sessions

// Remove WYSIWYG Editor
function remove_wysiwyg( $hook ) {
    global $post;
    global $pagenow;

    if ( $pagenow== 'post-new.php' && isset($_GET['post_type'])) || // if a new post page check the post type from the URL
       (($pagenow== 'post.php' ) && // If editing  existing post check the post type of the post
          (($post->post_type != 'post') && ($post->post_type != 'page')))
      add_filter('user_can_richedit', '__return_false');
}

add_action( 'admin_init', 'remove_wysiwyg' );      
share|improve this answer
    
lol, looks like me and milo where writing at the same time. give the score to him as he was first –  Mark Kaplun Jan 25 '13 at 6:43

A bit involved, but this should work:

function remove_wysiwyg() {
    global $pagenow;
    if ( 'post.php' == $pagenow ) {
        $type = get_post_type( $_GET['post'] );
        if( 'post' != $type || 'page' != $type )
            add_filter('user_can_richedit', '__return_false');
    } elseif ( 'post-new.php' == $pagenow ) {
        if( isset( $_GET['post_type'] ) && 'page' != $_GET['post_type'] )
            add_filter('user_can_richedit', '__return_false');
    }   
}
add_action( 'admin_init', 'remove_wysiwyg' );
share|improve this answer

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.