How to Disable Post Revision History or Version Tracking in WordPress

Wordpress provide a great feature of maintaining Revisions or History of a Post. Since WordPress 2.6, whenever you create a post in WordPress, it keeps on maintaining history. This feature might be very useful in a multi-author blog where more then one user is contributing in a post, but it may simply not required when you are the only one contributing in that post. Not only does WordPress create and stores all the past revision automatically every 10 minutes or so, it causes your server MySQL database to be bloated with unwanted data. Within a few months, your ‘wp_posts’ table will be filled up, clustered, and the post ID will be gigantic. Worst case scenario when you backup your MySQL is to have a 50MB database, too big for uploading in case of server failure. So how to disable automatic revision history creation in wordpress? Simply follow these steps:

Disable WordPress Revision History

  1. Open your wp-config.php file which will be in wordpress root installation directory.
  2. Paste following line anywhere in that file.
    define(’WP_POST_REVISIONS’, false);
    Code language: Arduino (arduino)
This will simply disable Auto Revision History creation from wordpress.

Delete previous Revision Histories in WordPress

Using above technique will not delete your previous saved post revisions, to remove previous post revision permanently, run this query using the PHPMyAdmin:
DELETE FROM wp_posts WHERE post_type = “revision”;
Code language: SQL (Structured Query Language) (sql)
Now all post revisions related records should have been purged from your SQL database and all revision history should have been deleted.

View Comments

  • After it you need to run [ OPTIMIZE TABLE "wp_posts" ].
    Cause deleting lots of rows at a time, increase the overhead of table.
    To see overhead of table
    1. Login to phpMyAdmin
    2. Select the affected database. Last column label with overhead'.

  • I want to warn you against your sql query which is not very clean :

    you should use :

    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';

    if you want to delete all related datas.. and there are many of them !

    use this request with ssh because it's a very long one..

  • Thanks for the advice. One thing to point out however. Your example only worked once I converted the smart quotes to straight quotes.

    Cheers,

Share
Published by
Viral Patel
Tags: wordpress wordpress tips

Recent Posts

  • Java

Java URL Encoder/Decoder Example

Java URL Encoder/Decoder Example - In this tutorial we will see how to URL encode/decode…

5 years ago
  • General

How to Show Multiple Examples in OpenAPI Spec

Show Multiple Examples in OpenAPI - OpenAPI (aka Swagger) Specifications has become a defecto standard…

5 years ago
  • General

How to Run Local WordPress using Docker

Local WordPress using Docker - Running a local WordPress development environment is crucial for testing…

5 years ago
  • Java

Create and Validate JWT Token in Java using JJWT

1. JWT Token Overview JSON Web Token (JWT) is an open standard defines a compact…

5 years ago
  • Spring Boot

Spring Boot GraphQL Subscription Realtime API

GraphQL Subscription provides a great way of building real-time API. In this tutorial we will…

5 years ago
  • Spring Boot

Spring Boot DynamoDB Integration Test using Testcontainers

1. Overview Spring Boot Webflux DynamoDB Integration tests - In this tutorial we will see…

5 years ago