Black Friday - Cyber Monday Sale
30% OFF All Premium Licenses
  • 00 Days
  • 00 Hrs
  • 00 Mins
  • 00 Secs
Use code
SIGMA30

This 30% discount applies only to the first year. From the second year, renewals are charged at the regular price.

What are WordPress trashed posts and how to clean them?

Younes JFR.

What are trashed posts?

When you delete a post, page, or any custom post type in WordPress, it isn’t permanently removed right away. Instead, it’s moved to the trash, allowing you to restore it later if needed. Over time, these trashed posts can build up in your database, especially if you frequently delete old or test content.

How they affect your database?

Trashed posts remain stored in the wp_posts table with the status trash. Although they are hidden from your site’s front end, they still occupy space in your database. This can slightly slow down queries and increase the size of your backups or exports, especially on sites that handle large amounts of content.

How to clean them?

1. Using Advanced Database Cleaner plugin

You can easily remove trashed posts using the General Cleanup module in Advanced Database Cleaner plugin.

This method is safe, flexible, and fully automated. You can customize the cleanup to:

  • Delete all trashed posts or keep only recent ones (for example, keep trashed posts newer than X days).
  • Use the Keep Last feature to retain a specific number of trashed items if needed.
  • Schedule automatic cleanups so trashed posts are regularly deleted without manual effort.

2. Using a raw SQL query

If you prefer a manual method, you can run the following SQL query in phpMyAdmin for example:

DELETE FROM wp_posts WHERE post_status = 'trash';

In a multisite installation, this query must be executed separately for each subsite, replacing wp_ with the subsite’s table prefix (for example, wp_2_, wp_3_, etc.).

Note:
While you can manually run these SQL commands to clean trashed posts, we strongly recommend using the Advanced Database Cleaner plugin.
It uses WordPress’s internal cleaning methods, automatically handles multisite installations, and ensures that all related data is safely removed while keeping your database consistent and stable.