Hello guys, After a long time I’m here to write a tutorial to delete wordpress post revisions. Post revisions increase your database size and does bad effect on your site.
Post revisions are the auto saving drafts that are automatically stored in your databases. Whenever you are writing a post on WordPress, it creates post revisions when you click on “drafts”. The more you have a habit of clicking on drafts while writing posts the more space it takes on your databases.
Don’t create burden on your databases by ignoring your post revisions. Deleting post revision also improve your wordpress blog loading time.
So either disabling or limiting your WordPress post revisions can solve the solution. Here’s what you exactly need to do to limit WordPress post revisions to limit the burden on your databases.
How to Disable Post Revision
Step 1: Go to your WordPress root directory.
Step 2: Open wp-config.php
Step 3: Add the following code
define(‘AUTOSAVE_INTERVAL’, 300 ); // seconds
define(‘WP_POST_REVISIONS’, false );
This will disable your future WordPress posts revisions and increases your auto save interval from 60 seconds to 300 seconds (that means your posts will be auto saving every 5 minutes instead of each and every minute). You can also the increase the time count if you want by replacing the number.
How to Limit WordPress Post Revisions
If you want to limit the number of post revisions then add this code
Change the number 3 of your choice which you want.
How To Delete Previous Post Revisions
If you want to delete post revisions and associated data that is already in the database. So you will need access to your DB, either through command line ‘mysql’ or better with phpMyAdmin interface.
Select your database and execute this query:
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'
This will remove all revision posts and associated objects from the database.
After this I recommend you to OPTIMIZE tables (in phpMyAdmin just mark all tables and select Optimize) to compact your database.
Hope this tutorial will help you to Speed Up WordPress Load Time by disabling wordpress post revisions.