Delete, limit & deactivate WordPress revisions

What are WordPress Revisions?

Every time you save or update a post or page, WordPress automatically creates a revision and stores it in the database. A revision is a backup copy or temporary storage of articles and pages and you can use this to jump back to an older version of the content.

Why should I delete, limit or disable WordPress revisions?

Unfortunately, while this feature can be very useful, it has a negative impact on your site’s performance. Imagine you have 200 posts on your site and each of those posts has 10 revisions, then you have 2000 (unnecessary) entries of those revisions in your database. So this can bloat your database a lot and slow it down. Therefore, you should clean up or delete the revisions, especially if the website has been around for a while and it has never been done before.

Clean / delete WordPress revisions

Since changes are made to the database here, a backup should be made beforehand!

Delete revisions via plugin

The simplest and most comfortable solution is to clean up the revisions with a plugin. There are a variety of plugins that can get the job done. The best plugins for this are, for example: WP-Sweep and WP-Optimizie. But most caching plugins such as WP Fastest Cache or WP Rocket also offer the option of deleting revisions.

Delete revisions manually in the database

To “manually” delete your revisions, you need to run a SQL command on your database. So this variant is only for people with technical know-how and who know exactly what they are doing here. With this variant, it is particularly important that a backup of the database is made beforehand! The SQL command to delete the revisions from the database is as follows.
DELETE FROM wp_posts WHERE post_type="revision"

Note the table prefix “wp_” here and adjust it if necessary because you may have specified a different prefix when you installed WordPress.

Limit / restrict number of WordPress revisions

By limiting the number of WordPress revisions, you can prevent the database from becoming so bloated by revisions in the future. You can easily set the maximum number of revisions per post/page with a line of code that you have to add to the wp-config.php file.
It is recommended to select a maximum value of 3 here, but the value can of course be chosen freely.
So add the following code to your wp-config.php file and adjust your desired number of revisions in the code if necessary.
define('WP_POST_REVISIONS', 3);

This line of code must over the line with

“if ( ! defined( ‘ABSPATH’ ) ) {“

placed in your wp-config.php file.

Completely disable WordPress revisions

As an alternative to limiting revisions, you can also completely deactivate the revisions so that no revisions are created at all. Everyone has to decide for themselves whether this makes sense.
To disable the revisions you have to do the same as for limiting revisions and add a line of code (the same as for limiting) to the wp-config.php file. Instead of specifying the number of revisions as the value, this is now replaced by “false”.
So add the following code to the wp-config.php file.
define('WP_POST_REVISIONS', false);

If this setting is set, the existing revisions are not automatically deleted. They may therefore have to be deleted later.

WordPress Website Kosten IONOS Previous post What does WordPress cost? The WordPress website costs at a glance
Next post WordPress 5.6 released