Web development , php , ajax , symfony, framework, zend
In: web resources
20 Mar 2010WordPress automatically creates revisions of your content. Whenever you save a post or a page, the old version is retained so you can revert back at any time. Older revisions are never deleted so you always have a full history of all page changes.
However, sometimes it’s necessary to do a little housekeeping. Every revision requires a separate row in WordPress’s posts table and perhaps multiple entries in the postmeta and term_relationships tables. Removing older revisions will free up disk space and ease MySQL’s processing burden.
I’m going to say this only once: BACK UP YOUR DATABASE! We’re about to run SQL statements directly on your MySQL tables and one tiny slip could trash your WordPress installation.
First, you need to find your WordPress table prefix which is specified in the following line of wp-config.php:
| 1 | $table_prefix = ’wp_’; |
| view plain | print |
$table_prefix = 'wp_';
wp_ is the default but it can be changed to give your installation a little additional security. We’ll assume wp_ has been specified in the following code.
To delete all revisions for all pages and posts, start a MySQL administration tool such as phpMyAdmin and run the following SQL statement:
| 1 | DELETE a,b,c |
| 2 | FROM wp_posts a |
| 3 | LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) |
| 4 | LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) |
| 5 | WHERE a.post_type = ’revision’; |
| view plain | print |
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';
(Remember to change all table references from “wp_” to your table prefix if necessary.)
If that’s a little too severe, you could remove all revisions prior to a specific date, e.g. the following statement will remove all revisions except for those made after January 1, 2010:
| 1 | DELETE a,b,c |
| 2 | FROM wp_posts a |
| 3 | LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) |
| 4 | LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) |
| 5 | WHERE a.post_type = ’revision’ |
| 6 | AND a.post_date < ’2010-01-01′; |
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'
AND a.post_date < '2010-01-01';
(Note that MySQL dates are specified using YYYY-MM-DD notation.)
Add the following statement to your WordPress wp-config.php file to permanently switch off post revisions:
| 1 | define(’WP_POST_REVISIONS’, false); |
define('WP_POST_REVISIONS', false);
The value can be set to ‘true’ to re-enable revisions.
Alternatively, you can use a positive integer to limit the number of permitted revisions, e.g.
| 1 | define(’WP_POST_REVISIONS’, 5); |
define('WP_POST_REVISIONS', 5);
This will create a maximum of 5 revisions per post, plus one for auto-saving purposes. Older revisions will be automatically deleted.
If this all sounds a little too scary, you’ll be pleased to know that there are a number of WordPress plugins offering revision control.
This blog delivers stylish and dynamic news for designers and web-developers on all subjects of design, ranging from: CSS, Ajax, Javascript, web design, graphics, typography, advertising & much more. Our goal is to help you communicate effectively on the web with an engaging website or functional interface.
3 Responses to How to Control Post Revisions in WordPress
Wackymacs
March 27th, 2010 at 8:42 am
Microsoft's Vista Enterprise website explains how to obtain it:
Most important is the Volume Licensing Program you will need. Please see here:
You can also contact a Volume Licensing Specialist:
In the United States, call (800) 426-9400, or visit the Microsoft Licensing Program Reseller page.
Hope this helps.
Serge M
May 18th, 2010 at 2:16 am
You can teach yourself at
It's free.
Nate
May 20th, 2010 at 5:53 am
I'm not quite sure how to answer that but I found a reference on the Quick Books web site regarding that info. See source below.