How to Empty WordPress Trash Automatically (Daily or Never)

Do you want to empty WordPress trash automatically every day? On a busy blog, deleted spam comments, drafts and old posts pile up in the Trash fast. We delete hundreds of spam comments every day on QuickOnlineTips, and the Trash used to hold thousands of items. WordPress cleans it out by itself, but only after 30 days. Here is how to empty WordPress trash daily, or skip the Trash completely.

Automatically empty WordPress trash daily

Quick answer: Add define( 'EMPTY_TRASH_DAYS', 1 ); to your wp-config.php file and WordPress will permanently delete trashed posts, pages, media and comments after one day instead of 30. Set it to 0 to turn off the Trash entirely, so “Trash” becomes “Delete Permanently”. Always back up wp-config.php first.

When does WordPress empty the trash?

By default WordPress keeps trashed items for 30 days, then a scheduled task (WP-Cron) deletes them permanently. This applies to posts, pages, attachments and comments. Spam comments are separate: Akismet deletes old spam automatically, usually after 15 days.

How to empty WordPress trash daily

  1. Connect to your site with your host’s File Manager, SFTP or SSH.
  2. Download a backup copy of wp-config.php.
  3. Open wp-config.php and add this line above /* That's all, stop editing! */:
define( 'EMPTY_TRASH_DAYS', 1 );
  1. Save the file. From now on, items in the Trash are deleted after one day.

Change the number to suit you, for example 7 for a week.

How to disable the WordPress trash completely

define( 'EMPTY_TRASH_DAYS', 0 );

With 0, WordPress removes the Trash and shows Delete Permanently links instead, with no undo. Use this only if you are careful, because a mistaken click cannot be reversed without a backup.

Empty the trash right now

  • Go to Posts > Trash, Pages > Trash or Comments > Trash and click Empty Trash.
  • For spam, open Comments > Spam and click Empty Spam.
  • With WP-CLI: wp post delete $(wp post list --post_status=trash --format=ids) --force

Make sure WP-Cron runs

Automatic deletion relies on WP-Cron, which runs when people visit your site. On low-traffic sites, or if you set DISABLE_WP_CRON, add a real server cron job that calls wp-cron.php every few minutes so scheduled cleanups happen on time.

More ways to keep WordPress lean

FAQ

Does emptying the trash speed up WordPress?

Slightly, by keeping database tables smaller, especially on sites with lots of spam comments.

Can I recover something after the trash is emptied?

Only from a backup. Keep regular backups before changing EMPTY_TRASH_DAYS.

Does EMPTY_TRASH_DAYS delete media files?

Yes, if media trash is enabled. By default, media is deleted permanently without going to the Trash.

How often do you empty your WordPress trash? Tell us in the comments.

Stuck on a gift? Try our free Gift Idea GeneratorIdeas for anyone by age, job, interests and budget, with Amazon.com and Amazon.in linksFind gifts →

Found this useful? Share it with someone who needs it.

Get our free weekly email: new tech guides and tools, no spam.

New and updated tech guides, a free tool worth bookmarking and one useful pick, once a week. No spam, unsubscribe anytime.

One email a week. Unsubscribe anytime. See our privacy policy.

Related Tech Guides

Leave a Reply

Your email address will not be published. Required fields are marked *

5 Comments

  1. Your site is very good. There are useful information and most importantly, for sharing great. Thank you.

  2. Great tip…. Will make use of it to save some time that can be invested in marketing

  3. Very handy tip about optimising wp database and free the database from spam comments. Any config hack to avoid spam comments will greately help the spam commenters in first place.