Skip to content
WordPress · Performance

Limit WordPress revisions without a plugin

Page builders save constantly, and every save stacks up another revision in your database. Left unchecked they bloat your site and slow saves to a crawl. Here is how to cap them with one line, no plugin needed.

Why and how to limit WordPress page revisions video thumbnail
▶ Watch the full walkthrough · 6:21

Plays via YouTube. Google may set cookies when the player loads. Privacy policy

Editor's note (July 2026): Both methods below still work exactly the same on current WordPress. The WP_POST_REVISIONS constant and the wp_revisions_to_keep filter are unchanged in WordPress 6.x, and WP-Optimize and Better Search Replace are both still actively maintained. One clarification: each revision is saved as its own full entry in your wp_posts table (not the postmeta table), which is why a runaway revision count bloats the database so quickly.

The short version

Add one line near the top of wp-config.php: define( 'WP_POST_REVISIONS', 12 );. That caps every post and page at 12 stored revisions instead of unlimited. Set it to 0 to turn revisions off completely. If you cannot edit wp-config.php, a small functions.php filter does the same job. Either way, clean out the revisions you already have with WP-Optimize first.

One line of config, a lighter database.
The problem

How WordPress revisions quietly pile up

Revisions are a genuinely useful safety net. WordPress saves a snapshot every time you update a post or page, so you can roll back to an earlier version whenever you need to. The trouble starts with modern page builders. Elementor, Beaver Builder, and Divi make saving so quick and frequent that you rack up revisions without ever thinking about it.

I ran into this the hard way when a site's pages started saving slowly and eventually hung completely. Digging in with WP-Optimize, I found 477 saved revisions in the database, on a site that was only seven pages long. Every one of those revisions is a full extra copy sitting in your posts table.

Why it matters

Why unlimited revisions slow your site down

Each revision is stored as its own entry in the WordPress wp_posts table. Those 477 revisions had ballooned that table to over 240 megabytes, against roughly 24 megabytes on a comparable finished site. That is ten times the weight for content nobody will ever look at.

The bloat has real consequences. Saving a page slows to a crawl, and heavier database operations start to fail. A URL search-and-replace, the kind you run when moving a site from a dev URL to the live one, can hang outright when it has to grind through an oversized table. If you want to check your own table sizes, both WP-Optimize and Better Search Replace will show them to you.

Method 1

Limit revisions in wp-config.php

The simplest fix is a single line in your wp-config.php file. Add it near the top:

wp-config.php
define( 'WP_POST_REVISIONS', 12 );

Replace 12 with whatever limit you want. I find twelve a good balance: enough history to undo real mistakes, not so much that it piles up. Set the value to 0 and WordPress stops storing revisions entirely.

Placement matters. This line only works when it sits near the top of wp-config.php. Add it at the bottom and it will not take effect. Put it above the /* That's all, stop editing! */ comment, up with the other define statements.

Method 2

Limit revisions with a functions.php filter

If you do not have access to wp-config.php, you can do the same job from your theme's functions.php using the wp_revisions_to_keep filter. Its bonus is that it hands you the post object, so you can set different limits per post type:

functions.php
add_filter( 'wp_revisions_to_keep', 'page_revisionLimit', 10, 2 );

function page_revisionLimit( $num, $post ) {
    // Keep 12 revisions for pages, the default for everything else.
    if ( 'page' === $post->post_type ) {
        return 12;
    }
    return $num;
}

Return the number of revisions you want kept for each type, and fall back to $num (the current default) for the rest. The one catch with this route: it lives in your theme, so if you switch themes and forget to carry the code over, revision limiting quietly stops.

The cleanup

Clear out the revisions you already have

Here is the catch neither method fixes on its own: capping revisions only limits new ones. The hundreds already sitting in your database stay put until you remove them. That is where WP-Optimize comes in. Run it to flush out the saved revisions and shrink the database back down.

So the right order for a bloated site is: clean first, then cap. Optimize the database to clear the backlog, then add the limiting code so it never builds back up. On a fresh site, just add the code from the start. I put the WP_POST_REVISIONS line straight into my development template, so every new project is capped automatically.

Common questions

Frequently Asked Questions

How do I limit WordPress revisions without a plugin?

Add define( 'WP_POST_REVISIONS', 12 ); near the top of your wp-config.php file, replacing 12 with your preferred limit. That caps stored revisions for every post and page. If you cannot edit that file, the wp_revisions_to_keep filter in functions.php does the same thing.

Where should the WP_POST_REVISIONS line go in wp-config.php?

Near the top, with the other define statements, above the "That's all, stop editing!" comment. Placed at the bottom of the file it will not take effect, which is a common reason the setting seems to do nothing.

How do I disable WordPress revisions completely?

Set the constant to zero: define( 'WP_POST_REVISIONS', 0 );. WordPress will stop saving revisions altogether. Most sites are better off keeping a small number rather than zero, so you still have a safety net.

Why is my WordPress database so large or saving so slowly?

Often it is revisions. Page builders save frequently, and each save stores another full copy of the page in the wp_posts table. Hundreds of revisions can bloat the database many times over, which slows saves and can hang operations like a database search-and-replace.

Does limiting revisions delete the ones I already have?

No. The limit only applies to new revisions going forward. To remove the ones already stored, run a database optimizer like WP-Optimize to flush them, then add the limiting code so they do not accumulate again.

The bottom line

A one-line fix with an outsized payoff

Capping revisions takes almost no effort and pays off every day after. One line in wp-config.php, or a short filter in functions.php, keeps your database lean, your saves fast, and your migrations from hanging on bloated tables.

For a site that has already piled up thousands of revisions, optimize first to clear the backlog, then add the limit to stop it coming back. On anything new, bake the line in from day one and never think about it again.

Disclosure: This post contains affiliate links. As an Amazon Associate I earn from qualifying purchases, at no extra cost to you. Affiliate links like these and my YouTube channel are what keep the site running.