Limit WordPress post revisions

WordPress automatically saves pages, posts and custom posts every 60 seconds. WordPress’s revision system has no limit on how many revisions it will save. So still present in our WordPress database is the 1st draft of this post written on 24th June 2022. Thankfully, auto-save limits to just 1 copy. To help maintain a clean database, we also want to limit WordPress post revisions. So we don’t keep a copy of this post that was created 10 weeks ago.

Limiting how many times we revise a WordPress post, will help to reduce our database size. But if you need to change a post then you need to change a post so lets limit WordPress revisions that are stored automatically instead.

Turning off revisions is another solution, but this is ill advised as it will leave you with no backup ‘just in case’ you need a backup of a draft post.

Please follow our WordPress Backup recipe before cooking

Limit WordPress Post Revisions

Limit WordPress Post Revisions

Limit how many draft posts WordPress keeps to maintain a healthy database
Computer Time 10 minutes
Total Time 10 minutes

Equipment

  • WordPress
  • FTP Software We use Filezilla

Ingredients  

  • WordPress Posts
  • WordPress Posts

Instructions
 

  • FTP onto your WordPress server
    FTP onto server
  • Open htdocs and locate config.php
    Locate wp-config.php
  • Add the following to wp-config.php
    define( 'WP_POST_REVISIONS', 3 );
    Edit wp-config.php
  • You could also disable revisions by adding
    define( 'WP_POST_REVISIONS', 0 );
    WP_POST_REVISIONS 0

Notes

You may need to change file permissions to be able to edit wp-config.php
If this is the case you may need to talk to your host provider to gain access

Struggling with the above recipe? Hire a chef to do it for you