Menü schliessen
Created: April 22nd 2016
Last updated: May 1st 2020
Categories: Databases,  IT Development,  IT Support,  MySQL,  Wordpress
Author: Marcus Fleuti

Delete Posts Revisions from Your Database(Wordpress)

Donation Section: Background
Monero Badge: QR-Code
Monero Badge: Logo Icon Donate with Monero Badge: Logo Text
82uymVXLkvVbB4c4JpTd1tYm1yj1cKPKR2wqmw3XF8YXKTmY7JrTriP4pVwp2EJYBnCFdXhLq4zfFA6ic7VAWCFX5wfQbCC

DB
WordPress has a lot of good features and one of them is Post Revisions. This was included in WordPress 2.6, even though this is a good feature, it can cause some problems. One of them is increase the size of your database. Depending on how long it takes you to write a post, you might have as many as fifty post revisions. Now you can manually delete them, or you can run a simple query which we will show you in this post and get rid of all these useless revisions.
First thing you need to do is login to your phpMyAdmin and select your WordPress Database.
Click on the SQL Button and enter the following query:

DELETE FROM wp_posts WHERE post_type = "revision";

In this code basically we looked up a table wp_posts and removed every post that had a post_type revision associated with it. Now depending on the size of your database, this may save you a lot of space.

Disabling Post Revisions

If you also want to disable the post revision system, you can add this line near the bottom of your wp_config.php file.

define('WP_POST_REVISIONS', false);

You can also save only the last 3 revisions by adding following code to wp-config.php:

define(‘WP_POST_REVISIONS’, 3);