21+ years in hosting · Jaipur, India · INR billing with 18% GST · 24/7 email support
Blog · WebJi® India

How to Limit WordPress Post Revisions

Quick answer

To limit WordPress post revisions, add define( 'WP_POST_REVISIONS', 5 ); to wp-config.php above the stop-editing line and save. WordPress then keeps five revisions per post, trimming older ones on the next save. Existing revisions stay until you delete them, after a backup, with WP-CLI, a cleanup plugin or SQL. Avoid 0, which removes rollback.

For WordPress site owners whose database keeps growing and who want to cap revision history without losing undo.

✓ In business since 2005
✓ INR + GST billing
✓ 24/7 Email Support — avg reply < 60 min
GuideWebJi®
knowledge
Read time
5 min
Sections
8
Updated
14 Nov 2026
Written by
WebJi® team

What are WordPress post revisions, and where are they stored?

A revision is a full copy of a post saved as its own row in the wp_posts table with post_type = 'revision'; by default WordPress keeps every revision forever. Each saved update or draft adds one, so a post edited forty times carries forty copies.

  • Where: wp_posts, with related rows in wp_postmeta (prefix may differ from wp_).
  • Autosaves: stored separately as one autosave per user per post, overwritten as you type, so they do not pile up the same way.
  • Front end: visitors never query revisions, so they do not slow page loads.
  • Back end: they enlarge the database, which slows backups, exports and migrations and uses quota.

How do you limit post revisions in wp-config.php?

Add define( 'WP_POST_REVISIONS', 5 ); to wp-config.php above the line "That's all, stop editing!", save, and WordPress keeps at most five revisions per post from then on. Constants below that line are read too late and ignored.

// wp-config.php, above "That's all, stop editing! Happy publishing."
define( 'WP_POST_REVISIONS', 5 );
define( 'AUTOSAVE_INTERVAL', 120 );   // optional: autosave every 2 minutes instead of 60 seconds
  1. Copy wp-config.php to wp-config.php.bak in File Manager or over SFTP.
  2. Add the line, making sure it is not duplicated elsewhere in the file.
  3. Save, reload the site, and confirm it still loads.
  4. Edit a post several times and check that its revision count stops at your number.

A white screen after saving usually means a missing semicolon or quote; restore the backup copy and try again. With WP-CLI, wp config set WP_POST_REVISIONS 5 --raw writes the same line safely.

Which WP_POST_REVISIONS value should you choose?

Pick a number, usually 3 to 10, rather than 0: a number keeps an undo history while capping growth, whereas 0 or false removes the ability to roll back an edit.

WP_POST_REVISIONS values and their effect
ValueBehaviourSuits
true or -1Keep every revision (the default)Rarely; this is what fills databases
3–5Keep that many per post; oldest dropped on the next saveMost business sites and single-author blogs
10Longer undo historyMulti-author sites with editors and client reviews
false or 0No revisions; only the autosave remainsOnly when content is backed up elsewhere

Developers can set different limits per post type with the wp_revisions_to_keep filter, for example more for long articles and fewer for products.

How do you delete revisions that are already stored?

A new limit trims a post only the next time it is saved, so clear the existing backlog separately, after a full database backup, using WP-CLI, a cleanup plugin or SQL. There is no undo for a database delete.

# WP-CLI: count, then delete all revisions
wp post list --post_type=revision --format=count
wp post delete $(wp post list --post_type=revision --format=ids) --force

# SQL in phpMyAdmin (check your table prefix first)
DELETE a, b, c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision';

If your prefix is not wp_, the SQL deletes nothing, which can look like success. In phpMyAdmin, use "Simulate query" first to see how many rows would be affected. On very large sites, delete in batches to avoid timeouts.

Plugins such as WP-Optimize or WP-Sweep do the same with a button and a schedule. The options table is often the next to bloat; see cleaning the wp_options table.

Why do revisions matter on shared hosting?

Revision rows count towards disk and database usage, and every backup and migration has to copy them, so a heavily edited blog can carry far more revision data than live content. Clearing them is safer than deleting media, because revisions are redundant once a post is final.

Database size also affects how quickly a host's backup job finishes and how long a restore takes in an emergency. If a site is near its plan's limits, revisions are usually the first and easiest space to reclaim. Hosting plans for WordPress sites are on the WordPress hosting page; if a database has already outgrown its quota, email support@webji.services, answered 24/7 in Hindi and English.

How do you check that the revision limit is working?

Watch two numbers: the revision count on a busy post, which should stop at your limit, and the database size in your hosting panel, which should grow much more slowly afterwards.

  1. Edit a post several times and confirm the revisions list stops at your number.
  2. Run wp post list --post_type=revision --format=count now and again in a month.
  3. If the count keeps climbing, search wp-config.php for a second WP_POST_REVISIONS line or one placed below the stop-editing comment.
  4. Repeat the cleanup after importing content from another site, since imports bring revision rows with them.

For overall database speed, the WordPress speed optimisation service includes database clean-up alongside caching and image work.

FAQ

Frequently asked questions

Will limiting revisions delete my published content?

No. The live post is its own row with post_type 'post' or 'page' and is never affected. Only older revision copies beyond your limit are removed when the post is next saved.

Do WooCommerce products have revisions too?

Products are a post type that supports revisions only if enabled, and WooCommerce does not enable them by default. Orders are stored separately. Check with wp post list --post_type=revision to see which parent posts the revisions belong to.

Can I limit revisions without editing wp-config.php?

Yes. Optimisation plugins such as WP-Optimize can set a limit, and a developer can add a wp_revisions_to_keep filter in a small custom plugin. The constant remains the simplest and most dependable method.

Does the block editor create more revisions than the Classic Editor?

Both create a revision on each manual save or update. The block editor's autosave works the same way, keeping one autosave per user. The number of revisions depends on how often authors click Save, not on the editor type.

Constants and commands checked against WordPress developer documentation and WP-CLI · Reviewed by the WebJi® team, Jaipur.

WebJi® since 2005

Ready to get started with WebJi®?

Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.