How to Change How Long WordPress Keeps Trashed Posts

When you delete a post or page in WordPress, it doesn’t vanish right away. Instead, it moves to the trash, where you can restore it if you made a mistake. WordPress automatically empties the trash every 30 days, but 30 days doesn’t fit every website. Some site owners want faster cleanup to reduce database size,…

David Allsop Avatar

Author

Date

Category

When you delete a post or page in WordPress, it doesn’t vanish right away. Instead, it moves to the trash, where you can restore it if you made a mistake. WordPress automatically empties the trash every 30 days, but 30 days doesn’t fit every website.

Some site owners want faster cleanup to reduce database size, while others want a longer recovery window in case someone deletes content by accident. The good news: you can customise the trash cleanup schedule with a single line of code.

In this guide, you’ll learn exactly how to change how long WordPress keeps trashed posts, with examples.


Change WordPress Trash Cleanup Time in wp-config.php

To change how long WordPress keeps deleted posts, pages, comments, and products, add this line to your wp-config.php file:

define( 'EMPTY_TRASH_DAYS', 1 );

Replace 1 with the number of days you want WordPress to wait before permanently deleting trashed content.


Keep Trash for Only 1 Day

Great for large sites that generate a lot of content – less database clutter:

define( 'EMPTY_TRASH_DAYS', 1 );

Empty Trash Immediately (No Recovery)

Deletes posts instantly with no undo option:

define( 'EMPTY_TRASH_DAYS', 0 );

Warning: Setting this to 0 disables the trash feature completely. Only use it if you’re sure you don’t need a recovery window. The links/buttons to trash become delete permanently.


Keep Trash for 90 Days

Safer for multi-author blogs, agencies, and content teams:

define( 'EMPTY_TRASH_DAYS', 90 );

Where to Add the Code

  • Connect to your site via FTP, or your hosting file manager
  • Open the wp-config.php file in your WordPress root directory
  • Add the line above this line:
/* That's all, stop editing! Happy publishing. */

Save the file – WordPress will automatically adjust the trash schedule


Why Change EMPTY_TRASH_DAYS?

The EMPTY_TRASH_DAYS setting controls how long WordPress keeps deleted posts, pages, and other content before permanently removing them. Adjusting this value isn’t just a technical tweak 0 it can meaningfully improve site performance, reduce storage usage, and provide a safer editorial workflow.

Depending on your site size and how many people manage content, changing this setting can help you strike the right balance between speed, efficiency, and protection against accidental deletions.

Improve Performance and Reduce Database Size

Large WordPress sites – especially e-commerce stores and busy blogs – create a lot of trashed posts, pages, and products. Leaving those items in the database for 30+ days can:

  • Slow down backups
  • Increase database size
  • Make hosting slower
  • Increase storage usage on shared servers

A shorter cleanup schedule keeps the database lighter and faster.

Save Hosting Storage

If you’re on shared hosting or have limited database storage, a smaller trash window reduces database bloat and backup sizes.

Longer Safety Window for Teams

If writers, editors, or clients access the site, accidental deletion happens. Setting EMPTY_TRASH_DAYS to 60–180 days offers a much safer buffer.


Recommended WordPress Trash Settings

The ideal trash setting depends on how your team works, how often content changes, and how quickly you want to keep the database lean. The table below offers recommended trash retention periods based on different goals and priorities.

GoalRecommended Value
Maximum safety + multiple editors60–120 days
Balanced cleanup + recovery14–30 days
Improve performance quickly
1–7 days
Delete instantly (no undo)
0 days

Choose the value that fits your workflow to keep your site fast and your content safe.


Manually Empty Trash in WordPress

Even with automation, you can manually empty the trash anytime:

  • Go to Posts > Trash > Empty Trash
  • Same for Pages, Comments, Media, or WooCommerce Products

This is useful if you’re cleaning a site before backups or migrations.


Final Thoughts

Changing how long WordPress keeps trashed posts is a small optimisation with big benefits:

  • Faster database performance
  • Smaller backups and archives
  • Safer content recovery for teams
  • Less clutter

Whether you want instant deletion or a 90-day safety net, EMPTY_TRASH_DAYS gives you full control.

Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.