Too many WordPress post and page revisions can slow down your website, increase your database size, and make backups take longer. Using a simple code snippet is an easy and safe way to limit the number of revisions WordPress keeps for each post and page, helping your site stay fast and well-optimized.
Why Limit Revisions?
Reduce database size
Improve site performance
Make backups faster
How to Limit Revisions
Method 1: Using a Code Snippets Plugin (Code Snippets, WPCode)
Install a Code Snippets plugin.
Add a new snippet and paste this code:
define(‘WP_POST_REVISIONS’, 5);
Save and activate the snippet.
Method 2: Directly in wp-config.php
(No Plugin Needed)
Using an FTP client or your hosting file manager, locate your WordPress root directory.
Open the file
wp-config.php
for editing.Add this line above the line that says
/* That's all, stop editing! Happy blogging. */
:
Save the file and upload it back if using FTP.
WordPress will now limit revisions to 5 per post.
Now WordPress will only keep 5 revisions per post. You can change the number if needed.
Learn More
Watch Imran Siddiq from Web Squadron explain it here:
Thanks to John Boreatti: WordPress Revision Snippet