Monday, October 15, 2012

Delete Revisions in WordPress

WordPress has a built-in function to auto-store the revisions of your posts/pages, which is a life saver functionality, in the unlikely event of losing the entire blog with the single key press. But at the same time, Once the blog is well formatted and published, having these revisions, is redundant, and it unnecessarily consumes disk space. There are two approaches to reclaim the space.
  1. Hard Coded Approach
    As the name implies, In this approach, Log in to WordPress install of MySQL Database and execute the following delete SQL.

    DELETE FROM wp_posts WHERE post_type = "revision";

    This approach is a simple approach, however, the tags, categories and other options associated with the posts are not deleted by this approach and they are continue to remains in the WordPress database.

    Having deleted the revisions, to prevent WordPress from creating new revision, Add the following line at the end of the wp-config.php file on the WordPress root directory (of course with in <?php .. ?> tag)

    define('WP_POST_REVISIONS', false);

  2. Plugin Approach
    There are many plugins available at the wordpress plugin repository, to delete the revision in the wordpress. Among them, Following are three simple plugins which you can choose and install it your WordPress. They are as follows
    1. Better Delete Revisions
    2. Delete Revision
    3. Revision Control