WordPress tip: Get rid of unused post revisions

Just run the following query on your WordPress database, and all revisions (As well as meta associated with it) will be deleted from your database.
Of course, do not forget to make a backup of your database before running the code.

DELETE a,b,c
FROM wp_posts a
WHERE a.post_type = ‘revision’
LEFT JOIN wp_term_relationships b
ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id);

If you’d like to see more SQL queries for WordPress, make sure to read this post.
Thanks to One Extra Pixel for this cool query!
Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!WordPress tip: Get rid of unused post revisions

You Might Also Like...

  • WordPress tip: Get rid of unused shortcodes

    2075 readersWordPress shortcodes are great, but they have a bad point: When you decide to stop using them, their code stay in your post content. Here is a fix: A simple SQL query to run on your database to get rid of unused shortcodes. Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month

  • WordPress trick: Change theme programatically

    1675 readersIn WordPress, changing themes are easy. But what when you have to change a theme programmatically? Just read the following recipe to find out. It's a lot easier than you may think!Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!WordPress trick: Change theme programatically

  • Protect your WordPress blog using .htaccess

    1807 readersThe .htaccess file have lots of possibilities. Today, let's see how we can protect our WordPress blog from scripts injection, and unwanted modification of _REQUEST and/or GLOBALS. Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!Protect your WordPress blog using .htaccess

  • How to display custom post types on your WordPress blog homepage

    1847 readersWordPress 3.0 will allow you to create custom post types, so what about being able to list those custom types on your blog homepage? This very useful piece of code will show you how you can do it.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for

  • Insert Google Analytics without editing your theme

    1044 readersI like to use Google Analytics, but the boring stuff is that when you switch themes, you'll have to re-insert the code in the new theme. To avoid it, let's use the power of WordPress hook to insert our analytics code without editing theme files.Looking for WordPress hosting? Try WP Web Host. Prices starts at

  • WordPress tip: Insert posts programmatically

    1586 readersDo you know that it is possible to insert post in WordPress programmatically? In this recipe, I'll show you how to do it easily.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!WordPress tip: Insert posts programmatically

  • How to disable image caption in WordPress post editor

    1641 readersFor each uploaded image, WordPress lets you enter a caption to describe the file. This is very cool, but sometimes you don't need captions at all. Here is how you can get rid of it.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!How to disable

  • How to automatically create a custom field when a post is published

    2442 readersEver wanted to be able to automatically create a custom field with a value when a post (or page) is created? Then this snippet is for you.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!How to automatically create a custom field when a post is

  • WordPress tip: Quickly secure plugin files

    2155 readersMany plugins are made of only *.php files and most of the time they do allow direct access. Depending on what's in your files that might be a potential security hole. Today's tip will show you how to prevent direct access to plugin files.Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month

  • WordPress hack: Use includes in your posts or pages

    1997 readersIncludes are a very handy functionnality of the PHP language. Unfortunely, there's no built in solution to include posts in other posts in WordPress. Today's recipe is a shortcode that will allow you to finally do includes. Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for