• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Startup Hero

The Official Blog Of Name Hero

Learn To Fly Above The Competition Get Started
  • HomeWelcome
  • CoursesVideo Training Center
  • About UsWhat is StartupHero?
  • BlogGet the latest
  • Start HereStartup 101
  • SpeakingPodcast & Media
  • ResourcesTools to help You
    • Reselling WordPress Hosting
    • Resell Hero
    • How To Start A Blog
  • NameHeroCloud Web Hosting

How To Limit Post Revisions In WordPress Without a Plugin

By Bhagwad Park on April 4, 2022 0

How To Limit Post Revisions In WordPress Without a Plugin

In an earlier article, I’d talked about some WordPress maintenance tasks that you should do regularly. One of them was limiting the number of post revisions that WordPress saves by default. However, in that article, I’d mentioned a plugin you could use that did several different maintenance tasks at once from the same interface. But if you just want to know how to limit the number of post revisions in WordPress without a plugin, this tutorial is for you!

WordPress Saves Unlimited Revisions by Default

Whenever you make a change and save either a published post or a draft, WordPress saves a copy of the revision in its database, enabling you to revert to it whenever you want. Here’s a screenshot showing 10 post revisions that I made to a test post:

Unlimited Post Revisions in WordPress
Unlimited Post Revisions in WordPress

This number increases without limit as time goes by, and you can imagine that if you have lots of posts on your site, the sheer weight of the revisions will keep piling up. I don’t think they take up too much storage space, but why have the remnants of posts long gone? It creates unnecessary rows on in your tables, and it smacks of poor housekeeping.

Instead, what we want to do, is to put a limit on this useful feature – we don’t want to disable it entirely. I find a limit of 3 to be pretty good. But you can go ahead and set it higher – to maybe 10 if you want. Anything as long as it’s not infinite!

Here’s how we can limit the number of post revisions that WordPress saves by default.

Updating the wp-config.php File

In the root directory of your blog, there’s a very important file called “wp-config.php”. This is where all the access information for your site’s databases is stored, and it’s also where WordPress keeps a lot of important configuration data. We can modify this file to include a special variable that instructs WordPress to keep a specific number of post revisions. The name of the variable is:

WP_POST_REVISIONS

To open wp-config.php, go to your web hosting’s admin panel (usually cPanel), and open the file manager. Now navigate to the WordPress home directory, locate wp-config.php and open it. But before you make any changes, be sure to take a backup if this is your first time editing the wp-config.php file. It’s a very delicate file, and you can completely hose your WordPress site if you’re not careful!

There, you insert the following line:

define( ‘WP_POST_REVISIONS’, 3 );

Here’s a screenshot of where you can place it:

Adding a Line to wp-config.php to Limit Post Revisions
Adding a Line to wp-config.php to Limit Post Revisions

Make sure you put this line above the line which says “That’s all, stop editing! Happy blogging”. Don’t forget to include the semi-colon at the end of the statement. Save your changes, and you’re done!

Verifying that the Post Revisions Limitation is Working

Once you’ve made the change above, go to any post and save your changes. The changes for each post won’t take effect until you’ve tried to save it at least once. But as soon as you click the “save” or “update” button, the number of post revisions will be restricted to the number you set in wp-config.php. Here’s a screenshot showing that I now have only 3 post revisions as opposed to 10 from the same post I showed earlier:

Limiting Post Revisions in WordPress

And that’s it! With a simple line change, you’ve implemented a site-wide policy of limiting WordPress post revisions without needing to install a plugin. It’s a neat solution that works very nicely. I hope you found this useful!

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Reader Interactions

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Connect With Us!

Superhero Resources

Fix Common Issues

  • How To Setup Free And Automatic SSL Certificates
  • How To Setup Cloudflare With Railgun
  • How To Fix Memory Exhausted Errors In WordPress
  • How To Edit PHP Version/Upload Limit/Add Extensions
  • How To Move/Migrate Your Business To Name Hero

Free Guides

  • How To Setup NameHero Hosting
  • How To Create A Web Hosting Business With WordPress
  • How To Start A WordPress Blog
  • How To Migrate WordPress To A VPS
  • How To Speed Test And Optimize Your WordPress Website
  • Magento 2.X Installation Guide
  • How To Clean Up A WordPress Hack

Training

Recent Posts

  • The Best WordPress Plugin To Combat Plagiarism
  • Is It Time to Bring Back Blog Comments?
  • Two Filters That No Longer Work In Gutenberg (And Workarounds)
  • Migrating To The New Cloudflare Managed Rules Interface
  • How To Sort Posts By The “Last Modified” Date
  • How To Make WordPress Send E-mail From Another Address
Subscribe in a reader
  • Web Hosting
  • WordPress Hosting
  • Reseller Hosting
  • VPS Hosting
  • Twitter
  • Facebook
  • LinkedIn
  • YouTube
  • FTC Disclosure
  • Earnings Disclosure
  • Privacy Policy

Copyright © 2023 · Smart Passive Income Pro on Genesis Framework · WordPress · Log in