I know the title sounds a little wired, here is the background story. WordPress has Revisions system stores a record of each saved draft or published update. It is enabled for Post & Page. But in Custom Post Type, Revisions support is up to the theme developer to enable it. As long as you use themes, you should have noticed that, in some themes, the revisions is disabled on Custom Post Type by default. When Custom Post Type is used for short content such as Testimonial, it isn’t much of trouble to restore a revision. But not for a CPT post with a lot of content.
Being used to replying on revisions, a recent accident happened on one of my development site wiped off all the content in one CPT post. Unfortunately, the editor edit the content on the site without a second copy. No backup, no revisions history. The attempt of retrieving content from browser history didn’t work. We were panic and desperate for a while, before I turned my last hope to Autosave.
There is only ever a maximum of one autosave for any given post. Autosaves are enabled for all posts and pages but do not overwrite published content.
After a folder search, I located the source code adding Custom Post Type in the theme file. And then added one extra line of code in register_post_type() to enable Revision support.
‘supports’ => array( ‘revisions’)
Believe it or not, this is the magic switch that brings Revisions back. From the revision history list, there is one entry for Autosave. Lucky me, I recovered the lost content from autosave.
Lessons learned:
- Setup a backup plan on every WordPress site, especially development site.
- Don’t leave Revision disabled in custom post type. It can save time.