WordPress.org

Forums

how to empty trash with 2000 posts at once? (4 posts)

  1. Marc Toensing
    Member
    Posted 5 years ago #

    Hi!

    I want to mass delete my trash with 2000+ Posts in it. Is there a mysql command to do so?

  2. Mark / t31os
    Moderator
    Posted 5 years ago #

    Please backup before running the query, i'll not take responsibility if something goes wrong as a result..

    DELETE p
    FROM wp_posts p
    LEFT OUTER JOIN wp_postmeta pm ON (p.ID = pm.post_id)
    WHERE post_status = 'trash'

    Join is optional, removes entries from the meta table (if they exist).

    Tested under MySQL 5.1 in Phpmyadmin.

  3. mlanger
    Member
    Posted 5 years ago #

    I'm also interested in emptying the trash. Before I try this query, I just want to confirm that it is designed to ONLY delete items with a post_status of "trash."

    This might be a dumb question, but my knowledge of MySQL is just enough to make me dangerous.

    And can I assume that the above query can be copied and pasted as is into the correct database query form?

    Yes, I WILL back up before attempting. But I don't want any surprises that occur as a result of my ignorance.

    Thanks.

  4. mlanger
    Member
    Posted 5 years ago #

    Nevermind. I couldn't wait and tried it anyway. It worked just as I hoped: it deleted all the posts in the Trash.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic