1

Is this possible to do somehow?

In some pages i use a custom box plugin and i don't need to show the content box on some of those pages. Is it possible to hide it by page template? Or ID if template is not possible?

6

I ended up using userabuser's answer with a small modification, because global $post doesn't seem to exist on init. You can instead just query for post in querystring, like so:

function remove_editor() {
    if (isset($_GET['post'])) {
        $id = $_GET['post'];
        $template = get_post_meta($id, '_wp_page_template', true);

        if($template == 'template_name.php'){ 
            remove_post_type_support( 'page', 'editor' );
        }
    }
}
add_action('init', 'remove_editor');
3

add this to functions.php

add_action('init', 'remove_content_editor');

function remove_content_editor() {
    remove_post_type_support( 'posttype', 'editor' );
}

Replace posttype with the name of the post type. It will remove the content editor from that post type's pages

1

To remove the editor based on template, you may do something like;

add_action('init', 'remove_editor');

function remove_editor() {
    global $post;
    $template = get_post_meta($post->ID, '_wp_page_template', true);

    //change 'page' to whatever post type you want to apply this to.
    if($template == 'template_name.php'){ 
        remove_post_type_support( 'page', 'editor' );
    }

}
  • Seems about right, i'll give this a shot. – qwerty Oct 17 '12 at 8:08
0

Following code works for me. (either specific pages or template)

add_action('admin_init', 'hide_editor');

function hide_editor() {    
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];

    if (!isset($post_id))
        return;
    // Hide the editor on the page titled 'Press and services' pages
    $hide_page = get_the_title($post_id);
    if ($hide_page == 'press') {
        remove_post_type_support('page', 'editor');
    }
    if ($hide_page == 'Services') {
        remove_post_type_support('page', 'editor');
    }
    // Hide the editor on a page with a specific page template
    // Get the name of the Page Template file.
    $template_file = get_post_meta($post_id, '_wp_page_template', true);
    //---
    if ($template_file == 'template-press.php') { // the filename of the page template
        remove_post_type_support('page', 'editor');
    }
    if ($template_file == 'template-service.php') { // the filename of the page template
        remove_post_type_support('page', 'editor');
    }
}

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.