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 have created a custom Post Type, and Registered it.

Can someone help me how to enable revisions to Custom Post type?

share|improve this question
2  
How did you register it? Using register_post_type or some plugin? –  kraftner Mar 24 at 15:32
1  
I though that revisions worked for all post types. Can someone confirm or deny that? –  s_ha_dum Mar 24 at 15:38
    
@s_ha_dum you need to enable it manually. There is no default set for "Revisions" in 'supports' in register_post_type. Only title and editor are set as default. Check the codex codex.wordpress.org/Function_Reference/register_post_type –  Pieter Goosen Mar 24 at 15:53
    
@PieterGoosen : thanks. I kinda hate revisions and think they are poorly implemented so I don't deal with them much. :) –  s_ha_dum Mar 24 at 15:55
    
@s_ha_dum I agree. I always disable revisions in wp-config. They take up unneccesary space in the db –  Pieter Goosen Mar 24 at 15:56

1 Answer 1

When you register your CPT, you need to manually add support for revisions. Only title and editor are set as defaults. Check out the codex. So if you need to enable revisions, you need to add it like this

'supports' => array( 'title', 'editor', 'revisions' ),

in your $args = array() when registering your CPT.

Just for info, here are the other arguments you can pass to 'supports'

'title'
'editor' (content)
'author'
'thumbnail' (featured image, current theme must also support post-thumbnails)
'excerpt'
'trackbacks'
'custom-fields'
'comments' (also will see comment count balloon on edit screen)
'revisions' (will store revisions)
'page-attributes' (menu order, hierarchical must be true to show Parent option)
'post-formats' add post formats, see Post Formats

EDIT

Thanks to @jammypeach, it is important to know, the revision metabox will not show up until there are actually revisions for the post. If there are no revisions, the revision meta box will not show

share|improve this answer
    
I have place in Support array. Works fine. Thanks, @pieter .. –  Bhanu Prakash Mar 24 at 16:30
    
@BhanuPrakash glad I could help. Just remember to tick my answer as accepted then. –  Pieter Goosen Mar 24 at 16:31
    
Something to consider - the Revisions box won't appear after enabling Revisions on your CPT unless you make some changes and save a few times first. This threw me, I thought my code wasn't working but (of course) there were no revisions to display. –  jammypeach Jul 28 at 14:20
    
@jammypeach will update my answer. Thanks for that. Not many people might know it, did not even considered that. Thanks :-) –  Pieter Goosen Jul 28 at 15:03

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.