1

The answer to this question is working great but I want to exclude the editor also when other templates are used. Can you please tell me how to extend the code to make this work with more than one template?

2

Yes, try this :

function remove_editor() {
    if (isset($_GET['post'])) {
        $id = $_GET['post'];
        $template = get_post_meta($id, '_wp_page_template', true);
        switch ($template) {
            case 'template_01.php':
            case 'template_02.php':
            case 'template_03.php':
            case 'template_04.php':
            // the below removes 'editor' support for 'pages'
            // if you want to remove for posts or custom post types as well
            // add this line for posts:
            // remove_post_type_support('post', 'editor');
            // add this line for custom post types and replace 
            // custom-post-type-name with the name of post type:
            // remove_post_type_support('custom-post-type-name', 'editor');
            remove_post_type_support('page', 'editor');
            break;
            default :
            // Don't remove any other template.
            break;
        }
    }
}
add_action('init', 'remove_editor');

Change the 'template_01.php' ... 'template_04.php' with your template names and if you want you can add more template names by adding more cases.
e.g.

case 'template_05.php':


However, the above code and the code from the answer requires you to first set the page templates from the page edit screen.
I hope this helps and clears how this works.

  • You're most welcome :) – devkabiir Feb 11 '17 at 11:09

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.