Database » Delete Unused Post Revisions 🛠️✔️

Delete Unused Post Revisions 🛠️✔️

Post revisions are a WordPress feature that allows you to undo changes and go back to an earlier version of your posts and pages, it works by auto-saving every 60s while you edit content.

Since revisions can take up a lot of space in the database, it is a good idea to delete them.

DELETE FROM wp_posts WHERE post_type = "revision";

or

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'

You can also limit the number of revisions WP keeps for every post/page by adding the following in wp-config.php file:

define( 'WP_POST_REVISIONS', 10 );

Replace 10 with the number of revisions you want to keep for each post.

See also  💡 How to use wp_delete_post to delete Posts or Pages

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended