WordPress Revisions help you to actually save and compare your drafts. Every update that you make to your existing post is recorded and saved as a revision. WordPress or any CMS will have this functionality because that is the only way to revert the changes that you might have done recently. Today let us see how to remove WordPress revisions if you have any.
Do you actually need WordPress Revisions?
Well this totally depends on how you do your updates or make corrections to your existing posts. As for me I do have a local XAMPP installation where I edit and preview the post before I publish them. So my revisions in live blog is very limited and most of them don’t exceed 2. But this could become a problem when i have thousands of posts in my blog, so i should either disable or delete them.
If you only have fewer posts in your blog which will never grow then it doesn’t matter, you can skip the rest of the post. But if you are having more number of revisions like 5 plus and you expect your posts to grow, then I think you should have a look into it.
Storing WordPress revisions doesn’t impact your post loading time, it will just take your database space and will load slower when you edit the post from the admin panel.
Kindly ensure you have a backup of your database before you try the below steps in your environment.
Remove WordPress Revisions
As of today there is no user interface option provided to delete your revisions, but let’s hope it will hit the road one day for sure. There are also plugins available to remove WordPress revisions but it is lot more easier to do it yourself. So for now let us just do it from phpMyAdmin page.
- Open the phpMyAdmin page. In my case I would navigate to http://localhost:81/phpmyadmin
- On the left side of the page you should see all the databases that are running on your server.
- Select the database that holds your WordPress installation (remember the database name that you had given during WordPress installation?)
1142 Select Command Denied
This happened to me on my local XAMPP wordpress installation, when I navigated to the database and selected the table wp_posts I was thrown the below error message.
Below steps can help you to quickly get rid of it. If you don’t see the error message you can skip these steps and proceed further.
1) Open the config.inc.php file from C:\xampp\phpMyAdmin
2) Locate the below line and comment it as shown in the screenshot
$cfg[‘Servers’][$i][‘pmadb’] = ‘phpmyadmin’;
3) Refresh your phpMyAdmin page by pressing CTRL + F5
- When you select the database, the list of tables are displayed under the Structure Tab, select the wp_posts table.
- You should now see all the values fetched from the table and displayed to you.
- The post_type column is what we are interested in. It tells us whether it is a page, attachment, post or revision. So this where all the revisions of your posts are stored.
- I just wanted to show you where these revisions are stored before you delete them. It’s always good to know things before you do something, isn’t it?
- Since we are hunting down revisions all you have to do is execute the below query, click on the SQL Tab in the phpMyAdmin page and enter the below MYSQL query and click on the Go button.
DELETE FROM wp36.wp_posts WHERE post_type = “revision”;
Where wp36 is my database name and wp_posts is the table name.
- You should see a message that confirms that the post revisions have been deleted.
Turn Off WordPress Revisions
If you are just starting new or you don’t want to delete stuff from your database then you can just turn off revisions without having to delete anything. But this will be only applied to your new posts and all your existing post revisions will be untouched.
- Open your wp-config.php file located at C:\xampp\htdocs\wordpress\
- Add the below lines at the end of the file.
/** Disable Revision once for all*/
define(‘WP_POST_REVISIONS’, false );
(or)
/** Disable Revision once for all*/
define(‘WP_POST_REVISIONS’, 0);
- If you still see the post revisions getting saved try movng the above line to first line in your wp-config.php file after the start of <?php tag. Now WordPress will no longer save revisions for your posts.
You can also limit the number of revisions stored for each post by changing the value 0 in the above query to the number you want.
Hey Sri,
I love learning how to do things without a plugin involved because to me less is best but I do use the WP Optimize plugin to remove unnecessary files from my database without me having to do this manually so often and it does clear the revisions too. Thank goodness because with everything that ads up you need to do that could be an extra amount of work each day.
Thanks for sharing this though, good to know. You’re so smart!
~Adrienne
Hello Adrienne, never heard of WP Optimize plugin, sounds cool will look into it for sure. I am not a person who wants to stay away from plugins but if there is something that i can do it myself then yes, i will go ahead and implement it on my own instead of leaning over the plugin. This gives me a better understanding on the platform that i use.
I perfectly agree that if you have to do something manually every time it’s a real pain but in this case you can turn off the WordPress Revisions once for all so that you don’t have to bother cleaning it up manually or using a plugin. Thanks for the wonderful comment, have a good day.