{"id":150662,"date":"2016-01-04T11:00:52","date_gmt":"2016-01-04T16:00:52","guid":{"rendered":"http:\/\/premium.wpmudev.org\/blog\/?p=150662"},"modified":"2017-05-25T07:20:02","modified_gmt":"2017-05-25T07:20:02","slug":"post-revisions","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/post-revisions\/","title":{"rendered":"How to Manage WordPress Post Revisions"},"content":{"rendered":"<p>WordPress automatically saves versions of your posts so you don\u2019t have to.<\/p>\n<p>Post revisions have been around since WordPress 2.6 and ensure your content is saved periodically do you can revert back to earlier versions of your posts when the unlikely happens, such as power outages or browser crashes.<\/p>\n<p>It\u2019s also a handy feature for writers. If you\u2019re working on an article and regret deleting a passage of text, you can look back over your previous drafts and undo any changes.<\/p>\n<p>In this post, we\u2019ll show you how to use post revisions, how to manage them and how to turn them off.<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-735x735 size-735x735\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/12\/revisions-box.png\" alt=\"Post revisions in WordPress.\" width=\"735\" height=\"442\" \/><figcaption class=\"wp-caption-text\">Revisions being tracked in a WordPress post.<\/figcaption><\/figure>\n<h3>Using the Post Revisions Editor<\/h3>\n<p>When you create a new post in WordPress, the post revisions feature kicks in and stores a record of each saved draft or published update.<\/p>\n<p>You can then access older versions of your posts and compare revisions. To do this, click on <strong>Browse<\/strong> in the post editor (as pictured above). You can then see what changes were made in each revision\u00a0by dragging a slider, or using the Previous and\u00a0Next buttons (pictured below).<\/p>\n<p>In the example below, you can see that a headline was change and new content was added to the post.<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-735x735\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/12\/basic-revisions-interface.png\" alt=\"Basic revisions interface.\" width=\"735\" height=\"609\" \/><figcaption class=\"wp-caption-text\">The basic revisions interface in WordPress.<\/figcaption><\/figure>\n<p>If you&#8217;re used to code diff tools, the basic layout of the page here will be familiar with the previous version on the left, newer version on the right, and differences highlighted visually. In addition to viewing the versions, you also have the option of restoring to a previous version entirely.<\/p>\n<p>Along with being able to compare adjacent versions, you can also highlight changes between completely separate versions by ticking the <strong>Compare any two revisions<\/strong> checkbox and then use the slider to select the options you&#8217;re after.<\/p>\n<p>In the example below, we&#8217;re comparing versions that aren&#8217;t immediately after one another:<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-735x735\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/12\/compare-two-revisions.png\" alt=\"Comparing two revisions in WordPress.\" width=\"732\" height=\"482\" \/><figcaption class=\"wp-caption-text\">Comparing two revisions from different time periods in WordPress.<\/figcaption><\/figure>\n<p>In terms of actual action items available to you here, the decision is basically to restore or not to restore. The biggest usability gripe you&#8217;re likely to run into is that it&#8217;s nigh on impossible to easily select and copy text from a particular revision directly from within the comparison view because it will inevitably select text from both posts.<\/p>\n<h3>Enabling Global Revisions<\/h3>\n<p>If you&#8217;re setting up WordPress from scratch, post revisions should be automatically enabled on your site with a default setting of storing every post revision.<\/p>\n<p>If you&#8217;re not seeing revisions as an option in your post settings, they&#8217;ve almost certainly been switched off at the configuration level. As a first step in working out what&#8217;s going on, pop open your\u00a0<em>wp-config.php<\/em>\u00a0file and look for a line like the following:<\/p>\n<div class=\"gist\" data-gist=\"0d89238bff4aafaf482b916445c46a43\" data-gist-file=\"disable-revisions.txt\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/0d89238bff4aafaf482b916445c46a43.js?file=disable-revisions.txt\">Loading gist 0d89238bff4aafaf482b916445c46a43<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div>\n<p>You&#8217;ve got three basic options when it comes to passing a value into <code>WP_POST_REVISIONS<\/code>:<\/p>\n<ol>\n<li><strong>true or -1:<\/strong> This is the default option in WordPress and makes it store every revision per post.<\/li>\n<li><strong>false or 0:<\/strong> This removes revisions entirely and limits you to the most recent autosave per post.<\/li>\n<li><strong>A number greater than zero:<\/strong> This limits your revision count to a specific number\u00a0and automatically deletes older revisions.<\/li>\n<\/ol>\n<p>There are two further small items worth pointing out at this stage: you need to set this value above where you define <code>ABSPATH<\/code> in your config file, and you also have the option of taking more control over your autosaves with <a href=\"https:\/\/codex.wordpress.org\/Editing_wp-config.php#Modify_AutoSave_Interval\" rel=\"noopener\" target=\"_blank\">AUTOSAVE_INTERVAL<\/a> as pictured below.<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-735x735\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/12\/setting-revisions-configuration1.png\" alt=\"Setting revisions options via wp-config.php.\" width=\"735\" height=\"196\" \/><figcaption class=\"wp-caption-text\">Setting revisions options via <em>wp-config.php<\/em>.<\/figcaption><\/figure>\n<p>If you don&#8217;t have access to your <em>wp-config.php <\/em>\u00a0file, or are still experiencing problems at this stage, you might have to reach out to your hosting provider. As an example, <a href=\"http:\/\/wpengine.com\/\" rel=\"noopener\" target=\"_blank\">WP Engine<\/a> disables revisions by default and <a href=\"https:\/\/wpengine.com\/support\/i-noticed-revisions-are-disabled-why-also-how-do-i-enable-them\/\" rel=\"noopener\" target=\"_blank\">require that you contact them<\/a> to enable the option.<\/p>\n<h3>Taking Control of Revisions on a Per Post Basis<\/h3>\n<p>If you&#8217;re comfortable with rolling up your sleeves and doing a little custom coding, you can also take advantage of the\u00a0<em><a href=\"https:\/\/codex.wordpress.org\/Plugin_API\/Filter_Reference\/wp_revisions_to_keep\" rel=\"noopener\" target=\"_blank\">wp_revisions_to_keep filter<\/a><\/em> to control how revisions are handled on a per post level.<\/p>\n<p>This is relatively straightforward to implement and simply involves passing in two parameters to the filter \u2013 the number of revisions to keep, and a <a href=\"https:\/\/codex.wordpress.org\/Class_Reference\/WP_Post\" rel=\"noopener\" target=\"_blank\">WP_Post<\/a> object representing the post to be targeted:<\/p>\n<div class=\"gist\" data-gist=\"2d81d77c8b6d9f12d296d9555e3eb6eb\" data-gist-file=\"revisions-to-keep.txt\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/2d81d77c8b6d9f12d296d9555e3eb6eb.js?file=revisions-to-keep.txt\">Loading gist 2d81d77c8b6d9f12d296d9555e3eb6eb<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div>\n<p>Obviously, you&#8217;re free to use the body of your function to get at the specific type of post you&#8217;re after in any way you like, so long as you are returning a valid object.<\/p>\n<h3>Turning Off or Limiting Revisions<\/h3>\n<p>While the post revision feature is handy for some, it&#8217;s not for everyone, particularly if you are limited database space or simply don&#8217;t need to autosave your posts.<\/p>\n<p>To completely switch off post revisions, add the following to your wp-config.php file:<\/p>\n<div class=\"gist\" data-gist=\"ac637ec59684f4a0cb94814c938b6a4c\" data-gist-file=\"turn-post-revisions-off\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/ac637ec59684f4a0cb94814c938b6a4c.js?file=turn-post-revisions-off\">Loading gist ac637ec59684f4a0cb94814c938b6a4c<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div>\n<p>If you want to re-enable revisions, simply set the value to &#8220;true.&#8221;<\/p>\n<p>Alternatively, if you want to limit the number of revisions of a post, you can use a number. For example:<\/p>\n<div class=\"gist\" data-gist=\"ce12d617ed3fa71bf57eda68979574cf\" data-gist-file=\"limit-post-revisions\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/ce12d617ed3fa71bf57eda68979574cf.js?file=limit-post-revisions\">Loading gist ce12d617ed3fa71bf57eda68979574cf<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div>\n<p>Adding this line to your wp-config.php file will create a maximum of\u00a010 revisions per post, plus one for auto-saving purpose. Older revisions will be automatically deleted as newer versions are stored.<\/p>\n<h3>Risks of Using Revisions on a Live Site<\/h3>\n<p>Taken purely as an aid to writers and editors, there&#8217;s very little to dislike in the concept of having revisions automatically enabled. The main knock against them comes in the context of performance on a live site.<\/p>\n<p>As each revision is stored as a separate entry in your database, there is a risk you could be unnecessarily hampering your database&#8217;s performance on larger sites by having them on.<\/p>\n<p>It&#8217;s difficult to give hard and fast indications as to how much of a negative effect this could have on individual sites, but <a href=\"https:\/\/wpmudev.com\/blog\/squeaky-clean-database\/\" target=\"_blank\" rel=\"noopener\">database optimization becomes ever more of a priority<\/a> as sites grow. With that in mind, let&#8217;s move on to some plugins you can use to keep your virtual house in order when it comes to minimizing database impact.<\/p>\n<h3>Using Plugins to Clear Out Revisions<\/h3>\n<p>Once you&#8217;ve gotten your head around the basic concept of revisions in WordPress, you may well find yourself looking to tidy up existing revisions on your site. After a piece is fully through the editorial process, the value of keeping all those revisions hanging around is often dubious at best.<\/p>\n<p>To finish up, we&#8217;ll point you in the direction of four handy plugins you can use to clear out revisions once you don&#8217;t need them anymore. As with any plugin that can potentially affect your database, make sure you have a <a href=\"https:\/\/wpmudev.com\/blog\/free-quality-backup-plugins\/\" target=\"_blank\" rel=\"noopener\">fully-functioning backup strategy<\/a> in place before testing any of these solutions.<\/p>\n<ul class=\"dev-tutorial-list\"><li class=\"dev-tutorial-list__item\"><header class=\"dev-tutorial-list__item__header\"><h3 class=\"dev-tutorial-list__item__title\">1. Optimize Database after Deleting Revisions<\/h3><\/header><section class=\"dev-tutorial-list__item__image\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"171\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/12\/optimize-database-600x171.png\" class=\"attachment-ratio-large size-ratio-large\" alt=\"1. Optimize Database after Deleting Revisions image\" aria-hidden=\"true\" \/><\/section><!-- end dev-tutorial-list__item__image --><section class=\"dev-tutorial-list__item__content\"><p>The Optimize Database after Deleting Revisions plugin gives you a way of pruning your revisions programatically and keeping database sizes optimized.<\/p>\n<p>The plugin can be called manually or set to run on a schedule, creates its own log files for later analysis, and enables you to choose a number of recent revisions to be excluded while cleaning.<\/p>\n<\/section><!-- end dev-tutorial-list__item__content --><footer class=\"dev-tutorial-list__item__footer\"><p>Interested in 1. Optimize Database after Deleting Revisions?<\/p><div class=\"dev-tutorial-list__item__cta\"><a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/rvg-optimize-database\/\" class=\"dui-btn dui-btn--sm dui-btn--brand dev-btn--Details\">Details<\/a><\/div><!-- end dev-tutorial-list__item__cta --><\/footer><!-- end dev-tutorial-list__item__footer --><\/li><!-- end dev-tutorial-list__item --><li class=\"dev-tutorial-list__item\"><header class=\"dev-tutorial-list__item__header\"><h3 class=\"dev-tutorial-list__item__title\">2. WP-Sweep<\/h3><\/header><section class=\"dev-tutorial-list__item__image\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"171\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/12\/wp-sweep-600x171.png\" class=\"attachment-ratio-large size-ratio-large\" alt=\"2. WP-Sweep image\" aria-hidden=\"true\" \/><\/section><!-- end dev-tutorial-list__item__image --><section class=\"dev-tutorial-list__item__content\"><p>WP-Sweep from Lester Chan\u00a0performs a wider WordPress housekeeping function, but also enables you to tame your revisions. The plugin is a useful way of tackling issues such as comments, drafts and revisions all in one go when it comes to keeping your site running clean.<\/p>\n<\/section><!-- end dev-tutorial-list__item__content --><footer class=\"dev-tutorial-list__item__footer\"><p>Interested in 2. WP-Sweep?<\/p><div class=\"dev-tutorial-list__item__cta\"><a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/wp-sweep\/\" class=\"dui-btn dui-btn--sm dui-btn--brand dev-btn--Details\">Details<\/a><\/div><!-- end dev-tutorial-list__item__cta --><\/footer><!-- end dev-tutorial-list__item__footer --><\/li><!-- end dev-tutorial-list__item --><li class=\"dev-tutorial-list__item\"><header class=\"dev-tutorial-list__item__header\"><h3 class=\"dev-tutorial-list__item__title\">3. WP-Optimize<\/h3><\/header><section class=\"dev-tutorial-list__item__image\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"171\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/12\/wp-optimize-600x171.png\" class=\"attachment-ratio-large size-ratio-large\" alt=\"3. WP-Optimize image\" aria-hidden=\"true\" \/><\/section><!-- end dev-tutorial-list__item__image --><section class=\"dev-tutorial-list__item__content\"><p>As with WP-Sweep, WP-Optimize enables you to trim a lot of fat from your WordPress database and clear up overflowing revisions while you&#8217;re at it. You&#8217;re free to create custom schedules for when it should run, and the plugin can help you blast through cleaning items such as unwanted draft posts, trashed comments, and much more besides.<\/p>\n<\/section><!-- end dev-tutorial-list__item__content --><footer class=\"dev-tutorial-list__item__footer\"><p>Interested in 3. WP-Optimize?<\/p><div class=\"dev-tutorial-list__item__cta\"><a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/wp-optimize\/\" class=\"dui-btn dui-btn--sm dui-btn--brand dev-btn--Details\">Details<\/a><\/div><!-- end dev-tutorial-list__item__cta --><\/footer><!-- end dev-tutorial-list__item__footer --><\/li><!-- end dev-tutorial-list__item --><li class=\"dev-tutorial-list__item\"><header class=\"dev-tutorial-list__item__header\"><h3 class=\"dev-tutorial-list__item__title\">4. Better Delete Revision<\/h3><\/header><section class=\"dev-tutorial-list__item__image\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"171\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2015\/12\/better-delete-revision-plugin-600x171.png\" class=\"attachment-ratio-large size-ratio-large\" alt=\"4. Better Delete Revision image\" aria-hidden=\"true\" \/><\/section><!-- end dev-tutorial-list__item__image --><section class=\"dev-tutorial-list__item__content\"><p>Better Delete Revision\u00a0limits itself solely to cleaning up revisions data, but takes a comprehensive approach and removes all meta information and tags relating to a particular revision while doing so.<\/p>\n<p>With over 60,000 active installs and a consistent star rating of close to\u00a0five, this plugin comes highly recommended, but it&#8217;s worth pointing out that it hasn&#8217;t been updated in nearly a year, so proceed carefully if you&#8217;re on a recent version of WordPress. You can find a nice breakdown of a typical Better Delete Revision workflow <a href=\"https:\/\/brianjackson.io\/delete-old-wordpress-revisions-db\/\" target=\"_blank\">over at Brian Jackson&#8217;s blog<\/a>.<\/p>\n<\/section><!-- end dev-tutorial-list__item__content --><footer class=\"dev-tutorial-list__item__footer\"><p>Interested in 4. Better Delete Revision?<\/p><div class=\"dev-tutorial-list__item__cta\"><a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/better-delete-revision\/\" class=\"dui-btn dui-btn--sm dui-btn--brand dev-btn--Download\">Download<\/a><\/div><!-- end dev-tutorial-list__item__cta --><\/footer><!-- end dev-tutorial-list__item__footer --><\/li><!-- end dev-tutorial-list__item --><\/ul><!-- end dev-tutorial-list -->\n<h3>Making the Most of Post Revisions<\/h3>\n<p>Post revisions is one of those tools in WordPress \u00a0you&#8217;ll kick yourself for not using previously if you haven&#8217;t taken advantage of it to date.\u00a0Let&#8217;s recap the main points to take away when considering using revisions on your site:<\/p>\n<ul>\n<li>You&#8217;re free to set basic parameters for revisions via <em>WP_POST_REVISIONS<\/em> in <em>wp-config.php<\/em>.<\/li>\n<li>You can take more fine-grained programmatic control on individual posts using the\u00a0<em>wp_revisions_to_keep<\/em> filter.<\/li>\n<li>Plugins such as WP-Sweep help minimize database bloat and keep things running smoothly behind the scenes.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>WordPress automatically saves versions of your posts and is a particularly useful feature during times when you forget to hit save and your browser crashes. Here&#8217;s how to use revisions properly, manage your drafts and even turn them off.<\/p>\n","protected":false},"author":37930,"featured_media":150792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[4,263],"tags":[9815],"tutorials_categories":[],"class_list":["post-150662","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-plugins","category-tutorials","tag-posts"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/150662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/37930"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=150662"}],"version-history":[{"count":26,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/150662\/revisions"}],"predecessor-version":[{"id":209578,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/150662\/revisions\/209578"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/150792"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=150662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=150662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=150662"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=150662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}