51

I have created a custom Post Type, and Registered it.

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

4
  • 2
    How did you register it? Using register_post_type or some plugin?
    – kraftner
    Commented Mar 24, 2014 at 15:32
  • 2
    I though that revisions worked for all post types. Can someone confirm or deny that?
    – s_ha_dum
    Commented Mar 24, 2014 at 15:38
  • 1
    @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 Commented Mar 24, 2014 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
    Commented Mar 24, 2014 at 15:55

1 Answer 1

85

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

8
  • I have place in Support array. Works fine. Thanks, @pieter .. Commented Mar 24, 2014 at 16:30
  • @BhanuPrakash glad I could help. Just remember to tick my answer as accepted then. Commented Mar 24, 2014 at 16:31
  • 17
    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
    Commented Jul 28, 2014 at 14:20
  • 1
    @jammypeach will update my answer. Thanks for that. Not many people might know it, did not even considered that. Thanks :-) Commented Jul 28, 2014 at 15:03
  • 1
    Thank you @jammypeach I just spent an hour trying to diagnose what I thought was a problem with the custom post type def itself- that is certainly a key bit of info!
    – nickpish
    Commented Apr 18, 2019 at 17:52

Your Answer

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

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