Skip to content
  • Quick Ref
  • Contact
  • About
wpcanyon.com

wpcanyon.com

Deleting, Limiting, and Disabling Post Revisions in WordPress

Posted on August 20, 2025August 20, 2025 By Admin No Comments on Deleting, Limiting, and Disabling Post Revisions in WordPress

Deleting, Limiting, and Disabling Post Revisions in WordPress

WordPress automatically saves post revisions to help you track changes and restore previous versions. However, excessive revisions can bloat your database, slow down your site, and complicate backups. This guide explains how to delete existing revisions, limit the number of revisions saved, or disable them entirely to optimize your WordPress site’s performance.

Quick Fix

  1. Delete all existing post revisions using a simple SQL query or a plugin.
  2. Limit future revisions by adding a line to your wp-config.php file.
  3. Disable post revisions completely by defining a constant in wp-config.php.

Why This Happens

WordPress stores each revision of a post as a separate entry in the database. Over time, especially on sites with frequent edits or multiple authors, these revisions accumulate and increase the size of your wp_posts table. This can lead to slower database queries and larger backups. Limiting or disabling revisions helps maintain a lean database and improves site speed.

Step-by-Step

1. Deleting Existing Post Revisions

You can remove all existing post revisions directly from your database using this SQL command. Run it via phpMyAdmin, Adminer, or any MySQL client connected to your WordPress database.

DELETE FROM wp_posts WHERE post_type = 'revision';

Note: Replace wp_ with your actual database table prefix if different.

2. Limiting Post Revisions

To limit the number of revisions WordPress saves per post, add the following line to your wp-config.php file, ideally just before the line that says /* That's all, stop editing! Happy blogging. */:

define('WP_POST_REVISIONS', 3);

This example limits revisions to the last 3 versions. Adjust the number as needed.

3. Disabling Post Revisions Completely

If you prefer to disable revisions entirely, add this line to your wp-config.php file:

define('WP_POST_REVISIONS', false);

Note that disabling revisions means you lose the ability to revert to earlier versions of your posts.

WP_Config Tweaks

The wp-config.php file controls many core WordPress settings. To manage revisions, use these constants:

Constant Value Effect
WP_POST_REVISIONS Integer (e.g., 3) Limits the number of revisions saved per post
WP_POST_REVISIONS false Disables post revisions completely

Example snippet to limit revisions to 5:

define('WP_POST_REVISIONS', 5);

Code Snippets

Delete Revisions via PHP (Optional)

If you prefer deleting revisions programmatically, add this snippet to your theme’s functions.php or a custom plugin and run it once:

function delete_post_revisions() {
    global $wpdb;
    $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type = 'revision'");
}
add_action('init', 'delete_post_revisions');

Important: Remove or comment out this code after running to avoid repeated deletions.

Disable Revisions via Plugin Filter

Alternatively, disable revisions using a filter in your theme or plugin:

add_filter('wp_revisions_to_keep', '__return_zero');

Common Pitfalls

  • Forgetting to backup: Always backup your database before running deletion queries or editing wp-config.php.
  • Wrong table prefix: If your WordPress database uses a custom prefix, update the SQL query accordingly.
  • Plugin conflicts: Some plugins may override revision settings or create their own revisions.
  • Performance impact: Running large DELETE queries on big databases may temporarily slow down your site.
  • Disabling revisions risks: You lose the ability to restore previous content versions if revisions are disabled.

Test & Verify

  1. After deleting revisions, check your database wp_posts table for remaining entries with post_type = 'revision'.
  2. Create or edit a post and verify that the number of saved revisions respects your limit.
  3. If disabled, confirm no new revisions appear after editing posts.
  4. Use plugins like WP-Optimize or Query Monitor to monitor database size and queries.

Works on

This guide works on WordPress sites running on:

  • Web servers: Apache, Nginx, LiteSpeed
  • Control panels: cPanel, Plesk, DirectAdmin
  • Database: MySQL, MariaDB
  • WordPress versions 4.0 and above

FAQ

Q: Will deleting revisions affect my published posts?
A: No. Deleting revisions only removes saved versions, not the current published content.
Q: Can I recover revisions after deleting them?
A: No. Once deleted from the database, revisions cannot be restored unless you have a backup.
Q: Is it safe to disable revisions?
A: It is safe but not recommended if you want to keep track of changes or revert edits.
Q: How do I know how many revisions a post has?
A: In the post editor, WordPress shows the number of revisions in the “Revisions” section or sidebar.
Q: Are there plugins to manage revisions?
A: Yes, plugins like WP-Optimize or Revision Control help manage, limit, or delete revisions.

Wrap-up

Managing post revisions in

Database & Revisions Tags:Database, Performance, WordPress

Post navigation

Previous Post: Automatically Create a Page on Theme Activation
Next Post: Displaying What Time Ago a Post or Comment Is Published in WordPress

Leave a Reply Cancel reply

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

Recent Posts

  • Top WordPress Themes for Blogs in 2025
  • WordPress Admin Panel Trick: Adding ID Field to the Posts Listing
  • Solution previous_posts_link and next_posts_link Not Working
  • Show Top Commentators in WordPress Without a Plugin
  • How to Style Admin Comments in WordPress

Recent Comments

    Archives

    • August 2025

    Categories

    • Admin & Blocks
    • Admin & UI
    • Automation
    • Automation & Plugins
    • Comments
    • Comparisons
    • Database & Revisions
    • Developer Snippets
    • Fixes & Errors
    • Media & Thumbnails
    • Queries & Pagination
    • Security
    • Speed & Security
    • Tips & Tricks
    • WooCommerce How‑tos
    • WordPress Snippets
    • WordPress Themes
    • Terms & Conditions
    • Affiliate Disclosure

    Copyright © 2025 wpcanyon.com.

    Powered by PressBook WordPress theme