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 would like to remove the visual editor from one specific page because if I edit this one page in Visual mode, it breaks the code. I want to make sure the client doesn't have this option on the particular page. However, I don't want to remove the html editor.

This line of code removes the visual editor and the html editor: remove_post_type_support('page', 'editor');

a closer look at remove_post_type_support: http://codex.wordpress.org/Function_Reference/remove_post_type_support

But I want to only disable the visual editor.

Initial testing, in functions.php for this theme, I have:

function remove_editor_init() {

 if ( is_admin() ) {
    if (is_page(2548)) { 


    remove_post_type_support('page', 'editor');
    }
 }
}
add_action('init', 'remove_editor_init');

However, the conditional statements is_admin() and is_page() don't seem to working together.

Any suggestions?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

In your code, calling the action admin_init makes is_admin() unnecessary. And, if not mistaken, is_page() is meant to be used in the front-end...

But the solution is the following (based on this Answer):

add_filter( 'user_can_richedit', 'wpse_58501_page_can_richedit' );

function wpse_58501_page_can_richedit( $can ) 
{
    global $post;

    if ( 28 == $post->ID )
        return false;

    return $can;
}
share|improve this answer
    
yep. brilliant! thank you –  Starfs Jul 16 '12 at 18:45
add comment

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.