{"id":1780,"date":"2020-07-11T19:18:57","date_gmt":"2020-07-12T02:18:57","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=1780"},"modified":"2020-07-11T19:18:59","modified_gmt":"2020-07-12T02:18:59","slug":"how-to-disable-and-remove-old-post-revisions-in-wordpress","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=1780","title":{"rendered":"How To Disable And Remove Old Post Revisions In WordPress"},"content":{"rendered":"\n<p>By JOHN HUGHES<\/p>\n\n\n\n<p>Occasionally updating or revising a post on your WordPress site isn\u2019t a time-consuming task. It also doesn\u2019t take up a lot of space. However, over time, revisions do start to add up and can eventually take up a considerable amount of space on your database.<\/p>\n\n\n\n<p>Whether you\u2019re in a pursuit to free up some much-needed space or prevent the matter altogether, disabling or removing old post revisions from your WordPress site is an available option. Doing either can help reduce database bloat and\u00a0optimize performance.<\/p>\n\n\n\n<p>In this post, we\u2019ll discuss what post revisions are and how they can be used. We\u2019ll explain why you\u2019d want to disable, limit, or remove them, and walk you how to do each one. Let\u2019s get started!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Is a Post Revision?<\/h2>\n\n\n\n<p><a href=\"https:\/\/wordpress.org\/support\/article\/revisions\/\" target=\"_blank\" rel=\"noreferrer noopener\">Post revisions<\/a>, which are sometimes referred to as revisions, are a built-in feature of WordPress. They are useful because they make it easy to revert to a previous version of a post and undo the changes you made.<\/p>\n\n\n\n<p>For example, let\u2019s say you decided to delete some paragraphs in your post. However, later, you realize that edit was a mistake and want to recover the information you eliminated. With post revisions, you can easily do that.<\/p>\n\n\n\n<p>In WordPress Gutenberg, this feature is located on the right navigation panel under&nbsp;<em>Document &gt; Revisions<\/em>:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/1adn3cp4l2-flywheel.netdna-ssl.com\/wp-content\/uploads\/2020\/02\/post-revisions.png\" alt=\"The revisions tracker on a WordPress blog post.\" class=\"wp-image-36448\"\/><\/figure><\/div>\n\n\n\n<p>If you\u2019re still using the Classic Editor, you can find the revisions under the Publish box, also in the right navigation panel:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/1adn3cp4l2-flywheel.netdna-ssl.com\/wp-content\/uploads\/2020\/02\/classic-editor-revisions.png\" alt=\"The post revisions tracker in the classic editor of WordPress.\" class=\"wp-image-36449\"\/><\/figure><\/div>\n\n\n\n<p>When you\u2019re viewing revisions, WordPress shows you the new information that was added as well as what was removed through respective highlighting. New changes will be highlighted in green:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/1adn3cp4l2-flywheel.netdna-ssl.com\/wp-content\/uploads\/2020\/02\/post-revision-changes.png\" alt=\"A preview of the post revisions in WordPress.\" class=\"wp-image-36450\"\/><\/figure><\/div>\n\n\n\n<p>There\u2019s also a mode to compare versions of the revisions. When you select the version you want, you can click on the&nbsp;<em>Restore This Version<\/em>&nbsp;button.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Would You Want to Disable, Limit, or Remove WordPress Post Revisions?<\/h2>\n\n\n\n<p>With the WordPress revisions system, each update or draft is recorded and gets stored in your WordPress database. While having the option to view the changes made to a post and restore previous versions can be super helpful, it can also take up space.<\/p>\n\n\n\n<p>The more revisions you make, the more bloated your database can get. Database optimization is an important part of WordPress site maintenance. Therefore, managing the revisions on your site is highly recommended. Removing old revisions, for example, can reduce the size of your backups.<\/p>\n\n\n\n<p>There are three main options to choose from for managing post revisions. You can disable them completely, limit how many are allowed, and remove the old post revisions. Below, we\u2019ll cover how to go about each of these, starting with disabling post revisions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Disable Post Revisions in WordPress<\/h2>\n\n\n\n<p>One way to prevent an accumulation of revisions from piling up in your WordPress database is to remove the opportunity for them to in the first place. You can do this by disabling post revisions.<\/p>\n\n\n\n<p>In order to disable post revisions permanently, locate your WordPress site\u2019s&nbsp;<em>wp-config.php<\/em>&nbsp;file that\u2019s located in the root directory. Add the following line of code at the very top:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">define( \u2018WP_POST_REVISIONS\u2019, false );<\/pre>\n\n\n\n<p>This line of code disables post revisions from being saved to your database in the future. If you\u2019d like to enable this option sometime in the future (for whatever reason), simply replace the line with:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">define( \u2018WP_POST_REVISIONS\u2019, true );<\/pre>\n\n\n\n<p>When you\u2019re done, be sure to save your changes before exiting. Completely disabling post revisions isn\u2019t necessarily something we recommend. There are other less drastic options you can pursue to optimize and manage revisions in your database. However, if you do want to do it, it helps to know that option is there and can easily be activated or deactivated when necessary.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Limit Post Revisions in WordPress<\/h2>\n\n\n\n<p>If you\u2019re like most people, you\u2019ll want to save a couple of post revisions for every post you add to your site \u2013 just to be on the safe side. For this, the best option is to set a limit on the number of post revisions that are saved to your database.<\/p>\n\n\n\n<p>You can do that by adding the following line to your wp-config.php file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">define( \u2018WP_POST_REVISIONS\u2019, 3 );<\/pre>\n\n\n\n<p>This line saves the three most recent post revisions instead of all of them, meaning the older ones are automatically deleted once newer versions are saved. You can replace the number three with another integer depending on your preference.<\/p>\n\n\n\n<p>Instead of limiting the post revisions to a pre-defined number, you can also increase the auto-save interval to save fewer revisions. To do this, open up your site\u2019s&nbsp;<em>wp-config.php<\/em>&nbsp;file and add the following line at the top:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">define( \u2018AUTOSAVE_INTERVAL\u2019, 600 );<\/pre>\n\n\n\n<p>By default, WordPress auto-saves your post revisions every minute (60 seconds). However, by adding this line it will save them every 10 minutes (600 seconds). This automatically reduces the number of post revisions that are stored in the database.<\/p>\n\n\n\n<p>If you shy away from coding or adding code to your site\u2019s&nbsp;<em>wp-config.php<\/em>&nbsp;file, you can always get the job done by installing a plugin, such as&nbsp;<a href=\"https:\/\/wordpress.org\/plugins\/wp-revisions-control\/\" target=\"_blank\" rel=\"noreferrer noopener\">WP Revisions Control<\/a>. After you install and activate this plugin, you can configure that number of post revisions allowed by going to<em>&nbsp;Settings &gt; Writing<\/em>:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/1adn3cp4l2-flywheel.netdna-ssl.com\/wp-content\/uploads\/2020\/02\/wp-revisions-control.png\" alt=\"The WP Revisions Control WordPress plugin.\" class=\"wp-image-36451\"\/><\/figure><\/div>\n\n\n\n<p>It\u2019s important that you understand that the techniques we covered so far disable or limit post revisions from being saved for future posts. What about the past revisions?<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How To Remove Old Post Revisions In WordPress (2 Methods)<\/h2>\n\n\n\n<p>In this section, we\u2019ll cover the two methods you can use to permanently remove old post revisions from your WordPress site\u2019s database. If you\u2019re familiar (and comfortable) with&nbsp;<a href=\"https:\/\/www.wpkube.com\/work-wordpress-database-11-useful-sql-queries\/\" target=\"_blank\" rel=\"noreferrer noopener\">SQL queries<\/a>, you can go with the first method. However, if you\u2019d prefer using a plugin then go ahead and skip right down to the second method.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method 1: Deleting Post Revisions Using Code<\/h2>\n\n\n\n<p>Deleting post revisions from your database is one of those things that you should be able to do without having to install a plugin (although there are plugins for it too, which we\u2019ll cover next). After all, you\u2019re trying to save space and installing a plugin generally goes against that.<\/p>\n\n\n\n<p>In order to delete all of your past post revisions from your site\u2019s database, login to the cPanel of WordPress site\u2019s hosting account and click on the&nbsp;<em>phpMyAdmin<\/em>&nbsp;icon.<\/p>\n\n\n\n<p>In the left navigation panel, find and click on your WordPress database. Click on the&nbsp;<em>SQL<\/em>&nbsp;tab:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/1adn3cp4l2-flywheel.netdna-ssl.com\/wp-content\/uploads\/2020\/02\/phpmyadmin-sql.png\" alt=\"The SQL tab from the phpMyAdmin dashboard.\" class=\"wp-image-36452\"\/><\/figure><\/div>\n\n\n\n<p>You\u2019ll be brought to the phpMyAdmin SQL interface. Next, where you can run an SQL query. You can do this by entering the following snippet of code:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">DELETE FROM wp_posts WHERE post_type = \"revision\";<\/pre>\n\n\n\n<p>Make sure to replace wp_ with your own WordPress database prefix. Then click on the&nbsp;<em>Go<\/em>&nbsp;button. This will initiate the command:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/1adn3cp4l2-flywheel.netdna-ssl.com\/wp-content\/uploads\/2020\/02\/run-sql-query.png\" alt=\"A snippet of code in the SQL query.\" class=\"wp-image-36453\"\/><\/figure><\/div>\n\n\n\n<p>This SQL query removes all posts from your database that have post_type = \u201crevision\u201d. You might want to\u00a0create a backup of your database\u00a0prior to running this query as an added security measure. In our opinion, it\u2019s always best to make backups of your database before you make drastic changes to it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method 2: Use a WordPress Plugin to Delete Old Post Revisions<\/h2>\n\n\n\n<p>Although deleting post revisions from your WordPress site can be accomplished by running a single SQL query, you might find it easier to\u00a0install a plugin\u00a0and let it do all the work. This might be because the plugin has added benefits (database maintenance, removes excess files etc.) or simply because you\u2019re not comfortable with programming.<\/p>\n\n\n\n<p>Whatever the reason, there are a variety of plugins you can use to delete old post revisions. One you might consider using is&nbsp;<a href=\"https:\/\/wordpress.org\/plugins\/wp-optimize\/\" target=\"_blank\" rel=\"noreferrer noopener\">WP-Optimize<\/a>:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/1adn3cp4l2-flywheel.netdna-ssl.com\/wp-content\/uploads\/2020\/02\/wp-optimize-plugin.png\" alt=\"The WP-Optimize WordPress plugin.\" class=\"wp-image-36454\"\/><\/figure><\/div>\n\n\n\n<p>Although this plugin offers a&nbsp;<a href=\"https:\/\/getwpo.com\/buy\/\" target=\"_blank\" rel=\"noreferrer noopener\">premium version<\/a>&nbsp;with advanced features, you can download it and use it to delete old revisions for free. WP-Optimize is an all-in-one plugin that you can use to optimize your WordPress database. In addition to using it to delete revisions, you can also use it for important maintenance tasks such as image compressing and caching.<\/p>\n\n\n\n<p>Once you install and activate the plugin, it will add a&nbsp;<em>WP-Optimize<\/em>&nbsp;menu item to your WordPress dashboard. To delete post revisions, you can navigate to&nbsp;<em>WP-Optimize &gt; Database<\/em>.<\/p>\n\n\n\n<p>Under<em>&nbsp;Optimizations<\/em>, you can check the box next to \u2018Clean all post revisions\u2019, then click on the&nbsp;<em>Run Optimization<\/em>&nbsp;button:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/1adn3cp4l2-flywheel.netdna-ssl.com\/wp-content\/uploads\/2020\/02\/database-optimizations.png\" alt=\"The optimization settings page on the WP-Optimize WordPress plugin.\" class=\"wp-image-36455\"\/><\/figure><\/div>\n\n\n\n<p>You can delete the plugin or deactivate it once you\u2019re finished with this process. That way, you don\u2019t have to worry about it taking up any unnecessary space in your WordPress database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping It Up<\/h2>\n\n\n\n<p>Post revisions don\u2019t slow your site down or threaten the User Experience (UX). They do, however, start to take up a lot of space on your site\u2019s database over time. Fortunately, limiting or removing old post revisions will clear up a significant amount of space on your database.<\/p>\n\n\n\n<p>As we discussed in this post, there are two methods you can use to disable, limit, or remove old post revisions from your WordPress site:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Manually deleting and disabling post revisions from your site\u2019s code.<\/li><li>Installing plugins such as&nbsp;<a href=\"https:\/\/wordpress.org\/plugins\/wp-revisions-control\/\" target=\"_blank\" rel=\"noreferrer noopener\">WP Revisions Control<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/wordpress.org\/plugins\/wp-optimize\/\" target=\"_blank\" rel=\"noreferrer noopener\">WP-Optimize<\/a>.<\/li><\/ol>\n\n\n\n<p>Which method are you most comfortable with for disabling\/removing old post revisions? Is there another method you use? Let us know in the comments section below!<\/p>\n\n\n\n<p>Reference\uff1a <a href=\"https:\/\/www.wpkube.com\/how-to-disable-post-revisions-in-wordpress\/\">https:\/\/www.wpkube.com\/how-to-disable-post-revisions-in-wordpress\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>By JOHN HUGHES Occasionally updating or revising a post on your WordPress site isn\u2019t a time-consuming task. It also doesn\u2019t take up a lot of space. However, over time, revisions do start to add up and can eventually take up a considerable amount of space on your database. Whether you\u2019re in a pursuit to free <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=1780\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5,178],"tags":[],"class_list":["post-1780","post","type-post","status-publish","format-standard","hentry","category-linux","category-wordpress"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/1780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1780"}],"version-history":[{"count":0,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/1780\/revisions"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}