Posts

How To Close, Delete, Limit Revisions On WordPress

There is a feature called revisions for articles, pages on WordPress. When you make changes to an article or page, it keeps the previous version of each change separately. But it can be annoying and harmful sometimes. For example, if you change ten times on an article or page, there will be 10 old revisions. As the content of your site and changes increases, it will cause your database to swell and slow down. So here I will show you how to delete, close, and limit these revisions.

Closing The Revisions

To turn off revisions, simply place the following code in your wp-config.php file. Do not forget to add this code to between the <?php and ?> Tags.

define('WP_POST_REVISIONS', false);

Limiting The Revisions

To limit the revisions, you simply need to place the following code in your wp-config.php file. You can specify the number as you like. The limit in this code example is set to three.

define('WP_POST_REVISIONS', 3);

Deleting The Revisions

There is a simple way to clear your revisions from the database. Most people do this with plugins, but I don’t think it is the right decision. It is the most efficient way to use WordPress with at least the plugin.

Whether you run the following SQL query on phpMyAdmin or run it elsewhere, the revisions will be deleted.

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'