John Boreatti WordPress code snippet to limit post revisions

Limit WordPress Post and Page Revisions

Read Time: ~2 minute(s)

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)

  1. Install a Code Snippets plugin.

  2. Add a new snippet and paste this code:

define(‘WP_POST_REVISIONS’, 5);

  1. Save and activate the snippet.


Method 2: Directly in wp-config.php
(No Plugin Needed)

  1. Using an FTP client or your hosting file manager, locate your WordPress root directory.

  2. Open the file wp-config.php for editing.

  3. Add this line above the line that says /* That's all, stop editing! Happy blogging. */:

define(‘WP_POST_REVISIONS’, 5);

  1. Save the file and upload it back if using FTP.

  2. 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

Search Engine Optimization Services in Alabang Muntinlupa City
Inquire about our services today!

RANDOM POST

Read more about Google and Yahoo DMARC requirements
Happycloud.ph

Google and Yahoo DMARC Requirements!

Google and Yahoo recently announced stringent requirements for bulk senders, mandating the implementation of DMARC (Domain-based Message Authentication, Reporting, and Conformance) beginning February 1, 2024. 

Continue Reading

PARTNER

HOSTINGER

(This is an affiliate link)
Get 20% off
with our Link!
  • Business Email
  • Cloud Hosting
  • Web Hosting
  • Virtual Private Server
20% OFF!
COOKIES:

By continuing to use this website, you agree to their use. Please read our Cookie Policy.