2

Any way to disable post revision on specific post types only?

2 Answers 2

7

Remove the revisions property inside the supports parameter of register_post_type().

Example

$args = array(
    // ...
    'supports' => array('title','editor','thumbnail','comments','revisions')
); 
register_post_type('book',$args);

Change to:

$args = array(
    // ...
    'supports' => array('title','editor','thumbnail','comments')
); 
register_post_type('book',$args);
1
  • Actually it turned out that it is disabled by default... so.
    – jayarjo
    Oct 3, 2011 at 19:08
9

If you don't have control over the post type registration, you an use the remove_post_type_support() function:

add_action('admin_init', 'disablew_revisions');
function disable_revisions(){
    remove_post_type_support('post', 'revisions');
}

If you also wish to disable autosave for specific post types, you can do this:

add_action('admin_print_scripts', 'disable_autosave');
function disable_autosave(){
    global $post;
    if(get_post_type($post->ID) === 'post'){
        wp_deregister_script('autosave');
    }
}
1
  • 2
    Nice answer. I'm thinking it might be a touch better to use wp_dequeue_script instead of wp_deregister_script for WP v 3.1+. Apr 16, 2012 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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