Disabling or Limiting Post Revisions in WordPress

Disabling or Limiting Post Revisions in WordPress

One of the great features that WordPress has to offer its users is revision management. WordPress will automatically create a new revision every time you save a post, or whenever you preview it. For most WordPress installations, controlling revisions will not be required, and they won’t require maintenance. For larger sites, or sites that are very space constrained, you can limit or disable the revision management functionality of WordPress.

This tutorial assumes you can access and modify the wp-config.php file within your WordPress installation. The changes noted below, will be made to the wp-config.php file. Revisions can also be controlled through various WordPress plugins, and if you are unable to make the changes required the wp-config.php file, you can search and file applicable plugins.

To limit the number of the revisions that WordPress will maintain per post, you can define the constant WP_POST_REVISIONS, using the number of revisions you wish to be maintained. This site, is currently set to keep 3 revisions per post, and as such is configured as shown below.

// 3 Revisions Per Post
define('WP_POST_REVISIONS', 3);

If you wish to completely disable the revisions functionality in WordPress, you’ll want to add the following line, leveraging the same WP_POST_REVISIONS as noted above, to your wp-config.php file.

// Turn Off Revisions
define('WP_POST_REVISIONS', false);

If you want to completely disable and remove any and all revisions, you can leverage the following SQL query to delete all revisions, and associated data from your WordPress database. This will remove all revision entries and associated data from the wp_posts, wp_term_relationships, and wp_postmeta tables. Your published entries will stay untouched, and only the posts tagged as revisions will be removed.

DELETE a, b, c
FROM wp_posts AS a
LEFT JOIN wp_term_relationships AS b ON (b.object_id = a.id)
LEFT JOIN wp_postmeta AS c on (c.post_id = a.id)
WHERE a.post_type = 'revision';

Author: daharveyjr

I’m a solution architect responsible for the design, development, implementation, testing, and maintenance of e-commerce operations and applications using the Hybris and WebSphere Commerce product suites and other web technologies such as Java, J2EE/JEE, Spring, PHP, WordPress and more. Twitter | Facebook | LinkedIn

Leave a Reply

Your email address will not be published.