How to Disable the Revision Feature in WordPress
Tags: wordpress
Published: 2021-01-18 03:08:19

<!-- wp:paragraph -->

<p>Revision is a WordPress feature that allows you to access individual records of saved drafts, or published posts. Therefore, you can review and restore any old versions of articles. If you want to learn more about Revision, refer to <a href="https://gretathemes.com/why-you-need-revision-in-wordpress/">this article</a> first.</p>

<p>After a long time of use, records created by this feature (that is called post revisions) will increase and take a lot of space in memory. So if you don't need them anymore, you should delete them to free up space and <a href="https://gretathemes.com/series/speed-up-website/">make the website run faster</a>. Additionally, you can <strong>disable the Revision feature</strong> in case you don't want to use it anymore. Let's see how to do it!</p>

<!-- /wp:paragraph -->

<!-- wp:heading -->

<h2>How to Delete All Post Revisions on the Website</h2>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p><strong>Note</strong>: Before deleting anything from the website database, you should <a href="https://gretathemes.com/backup-wordpress-site-manually-or-use-plugin/">create a backup of your website</a> to restore data in case something goes wrong. And don't forget to <strong>double-check to avoid deleting important post revisions</strong>!</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->

<h3>How to Delete Post Revisions with Code</h3>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>To delete all the existing post revisions on the website, go to <strong>phpMyAdmin SQL</strong> and run the following SQL query:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>DELETE FROM wp_posts WHERE post_type = "revision";</pre>

<!-- /wp:paragraph -->

<!-- wp:image -->

<figure class="wp-block-image"></figure>

<p><img class="aligncenter" src="https://i.imgur.com/swH5PqT.png" alt="Delete Post Revisions with Code in WordPress" width="1600" height="476" /></p>

<!-- /wp:image -->

<!-- wp:paragraph -->

<p>This code will delete all data whose <code>post_type</code> is <code>revision</code> in the database (this means deleting all existing post revisions).</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>For example, before deleting, my post had 2 revisions as follows:</p>

<p><img class="aligncenter" src="https://i.imgur.com/VoPEwIM.png" alt="Post Revisions on the WordPress Website" width="1330" height="623" /></p>

<!-- /wp:paragraph -->

<!-- wp:image -->

<figure class="wp-block-image"></figure>

<!-- /wp:image -->

<!-- wp:paragraph -->

<p>After running the above code, all post revisions have been deleted. And as you can see, there are no more post revisions at all:</p>

<p><img class="aligncenter" src="https://i.imgur.com/HUaBxGS.png" alt="Post revisions are removed" width="1332" height="613" /></p>

<!-- /wp:paragraph -->

<!-- wp:image -->

<figure class="wp-block-image"></figure>

<!-- /wp:image -->

<!-- wp:heading {"level":3} -->

<h3>How to Delete Post Revisions Using a Plugin</h3>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>If you find using code is so difficult and complicated, you can use a plugin instead. Some cleaning plugins also support this feature. I wrote an article about the top best cleaning tools which have this feature <a href="https://gretathemes.com/wordpress-cleaning-tools/">here</a> so you can refer to it and find a suitable one for your website.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<!-- wp:paragraph -->

<p>In this article, I use <a href="https://wordpress.org/plugins/wp-sweep/">WP-Sweep</a> plugin to delete post revisions because it is quite fast, easy to use, and effective. This plugin is free and available on wordpress.org so you just need to install and activate it as usual!</p>

<!-- /wp:paragraph -->

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>After <a href="https://gretathemes.com/install-wordpress-plugin/">installing and activating the plugin</a>, head to <strong>Tools</strong> &gt;<strong> Sweep</strong>. Then, go to <strong>Post Sweep </strong>&gt; <strong>Revisions </strong>and click <strong>Sweep </strong>to delete all post revisions on the website. Besides, you can hit the <strong>Detail </strong>button to check post revisions before deleting.</p>

<!-- /wp:paragraph -->

<!-- wp:image -->

<figure class="wp-block-image"></figure>

<p><img class="aligncenter" src="https://i.imgur.com/IGiyyi9.png" alt="Use WP-Sweep plugin in WordPress to Delete Post Revisions" width="1349" height="625" /></p>

<!-- /wp:image -->

<!-- wp:paragraph -->

<p>It's quite simple, right?</p>

<!-- /wp:paragraph -->

<!-- wp:heading -->

<h2>How to Disable the Revision Feature</h2>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>In case you don't need to use the Revision feature anymore and want to disable it so that post revisions won't be auto-generated in the future, add the following code to the <code>wp-config.php</code> file:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>define( 'WP_POST_REVISIONS', false );</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>To enable this feature, replace the code above with:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>define( 'WP_POST_REVISIONS', true );</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>However, I don't recommend you disable Revision because incase some troubles happen (such as the power cut, computer crashing), you will lose the draft and can't restore it. Imagine that you're typing a long post, then the computer crash, Revision is off and you must do all again. That's truly a disaster!</p>

<!-- /wp:paragraph -->

<!-- wp:heading -->

<h2>Last Words</h2>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>Unused post revisions are considered as a type of unused data in WordPress. Therefore, you should clean them periodically and regularly to help free up space for your site. If you want to clean up other unused data in WordPress, refer to <a href="https://gretathemes.com/clean-up-unused-data-wordpress/">this article</a>. Good luck and don't forget to follow our upcoming posts to get more useful techniques about WordPress!</p>