I'm writing a script to alter the post content column in the database and I just notice it has a lot of empty rows, these seem to be deleted posts that now have no content or anything, I don't like them.

Could i just DELETE from posts WHERE content = ''; without breaking anything?

The database has around 40k rows, i can't afford to break it, its backed up tho.

1 Answer 1


I'd imagine those rows with empty content are more often then not revisions rather than trashed posts. To make sure you don't delete stuff you want to keep I suggest you add the post_status to your SQL, using trash and auto-draft as value - the latter are the revisions. Btw the table column is called post_content not content. So your SQL would look something along the lines of the following:

DELETE FROM wp_posts
  WHERE post_content = ""
  AND   post_status = "trash"
  OR    post_status = "auto-draft";

You could of course use $wpdb and its delete method to achieve the same.

  • 2
    You probably want a AND post_type = "post" since it's quite common for custom post types to have empty content.
    – totels
    Sep 10, 2015 at 9:26
  • @totels You are not wrong, but it depends on, if you want to delete trashed posts and revisions only from the post post type or not. Sep 10, 2015 at 9:34
  • The OP does say "seem to be deleted posts that now have no content or anything" maybe I'm inferring too much.
    – totels
    Sep 10, 2015 at 9:38
  • @totels Let the OP decide, could be the generic posts for all kind of posts or the specific for posts from the post type post. Sep 10, 2015 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.