WordPress: Limit article and page revisions

Each time you edit a page or a post and store the current draft, WordPress saves the current state as an additional revision. Those revisions allow returning to a previous version of your posts, e.g. in case you made a mistake while editing.

The number of revisions stored this way is not limited by default. Especially on larger pages or blog posts with frequent changes this leads to unnecessary growth of the WordPress database. Since I never used the revisions on my own, I was looking for a way to at least limit the number of revisions created while writing new articles.

In most cases, such an ‘eternal archive’ is simply not necessary. Since WordPress automatically saves your current page every 60 seconds, you can easily use them to fix any mistakes.

In order to change the revision settings, you need to change the varible WP_POST_REVISIONS in the wp-config.php file.

In case you want to save not more than 3 revisions for example, add the following line to your WordPress configuration:

define( 'WP_POST_REVISIONS', 3 );

If you don’t want to create any revisions (except the autosaves created every 60 seconds), simply set WP_POST_REVISIONS to false.

After changing this setting, already existing revisions are not automatically deleted. You need to open an already existing post in the editor and save it again in order to remove the additional revisions.

As an alternative, you can use the plugin WP-Sweep to clean up older revisions. Please make sure you have a current backup of your WordPress database before performing these tasks.

Leave a Reply

Your email address will not be published. Required fields are marked *