Do you want more control over when and how WordPress deletes your trash? Maybe you want to keep deleted content around longer than the default 30 days in case you need to restore something. Or perhaps you‘d prefer WordPress to clean out the trash automatically more often to keep your site running lean and efficient. You might even want to bypass the trash system entirely and have WordPress permanently delete items immediately.
If any of those situations sound familiar, you‘re in the right place. In this guide, we‘ll dive deep into the WordPress trash feature and show you exactly how to customize its behavior to suit your needs.
Understanding the WordPress Trash System
First introduced way back in WordPress 2.9, the trash feature adds an important safety net to the content deletion process. Instead of being permanently deleted right away, trashed posts, pages, comments, and other items are sent to a holding area where they wait to be either restored or automatically deleted after a set period (30 days by default).
This gives you a second chance to change your mind if you accidentally delete something you meant to keep. You can think of the trash as being similar to the Recycle Bin on your computer, giving you a grace period to reverse accidental deletions.
However, relying too much on the trash to correct mistakes can lead to a bloated database and slower site performance over time. WordPress has to do extra work to manage all those trashed items until the auto-delete time rolls around. And if you have to regularly restore things from the trash, it‘s probably a sign that your content management process could use some refinement.
That‘s why many WordPress experts recommend adjusting the default trash behavior based on your specific needs and workflow. By controlling how long items stay in the trash or even disabling it completely, you can optimize your site‘s performance while still giving yourself the right amount of deletion safety net.
Trash Control Methods Comparison
WordPress offers a few different ways to take control of your trash settings:
| Method | Difficulty | Trash Disabled? | Auto-Empty Frequency | Notes |
|---|---|---|---|---|
| Empty Trash Button plugin | Easy | Optional | Custom # of days | Easiest method, adds settings to Dashboard |
| EMPTY_TRASH_DAYS define | Intermediate | Optional | Custom # of days | Requires editing wp-config.php |
| Custom filter code | Advanced | Yes | Never | Most control, requires PHP knowledge |
Let‘s go through each of these methods so you can decide which one is right for you.
Method 1: Empty Trash Button Plugin
By far the easiest way to customize your trash settings is by installing the free Empty Trash Button plugin.
After activating the plugin, head over to the Settings > Empty Trash Button page in your WordPress dashboard. There you‘ll see a new option to set the number of days to keep deleted content in the trash:

Simply enter the number of days you‘d like WordPress to wait before auto-emptying the trash. Some common time periods include:
- 1 day for daily trash emptying
- 7 days for weekly trash emptying
- 30 days for monthly trash emptying (WordPress default)
- 0 to disable trash and delete permanently
It‘s important to note that setting the number of days to 0 will cause WordPress to bypass the trash system entirely. Any content you delete will be immediately purged from your database with no way to restore it. Only use this option if you‘re absolutely sure you won‘t need to recover deleted content. And as with any major change to your site functionality, it‘s crucial to have a recent backup on hand just in case.
Method 2: EMPTY_TRASH_DAYS Define
If you‘re comfortable editing your WordPress files, you can control the trash auto-empty frequency by adding a simple code snippet to your wp-config.php file.
Caution: Always make a complete backup of your site files and database before editing wp-config.php. A single typo or misplaced character can bring down your whole site.
Open up wp-config.php for editing and look for the line that says "That‘s all, stop editing!" (usually around line 78). Just before that, add the following code:
define( ‘EMPTY_TRASH_DAYS‘, 60 );Replace 60 with the number of days you want WordPress to keep trashed items before deleting them permanently. You can use 0 here to bypass the trash system, but again, only do that if you‘re 100% comfortable with not being able to restore deleted content.
Save the changes to wp-config.php and re-upload it to your server. WordPress will now use your custom auto-empty days setting for the trash.
Method 3: Custom Filter Code
For advanced users who want maximum control and are comfortable writing PHP code, you can override the trash functionality with a custom filter.
One way to do this is by adding the following code to your currently active theme‘s functions.php file or a custom plugin:
function wpb_empty_trash_days() {
return 90; // Custom number of days
}
add_filter( ‘pre_option_empty_trash_days‘, ‘wpb_empty_trash_days‘ ); This filter function will set the trash auto-empty frequency to 90 days (or whatever you change the return value to).
You can also use this method to disable the trash system completely with a filter like this:
function wpb_disable_trash() {
remove_action(‘wp_scheduled_delete‘, ‘wp_scheduled_delete‘);
}
add_action(‘init‘, ‘wpb_disable_trash‘);With that code active, anything you delete in WordPress will immediately bypass the trash and be removed from the database.
Of course, there are many other ways you could customize trash behavior with filters and action hooks if you want to get fancy. You could set different auto-empty frequencies for different post types, automatically empty trash on a daily schedule, or display a custom admin notice warning users when something is moved to trash.
Trash Maintenance Best Practices
Regardless of which trash control method you use, there are some general best practices you should keep in mind:
- Always take a complete backup of your WordPress files and database before changing any core settings or functionality. You don‘t want one little mistake to cause catastrophic data loss.
- Be very cautious about disabling trash completely unless you have a reliable system in place to catch accidental deletions. The trash is a valuable safety net that can save you from massive headaches.
- If you do rely on the trash system, get in the habit of checking your trash regularly and permanently deleting anything you know you won‘t need to restore.
- Consider emptying your trash more frequently (daily or weekly) if you have a large or busy site to keep your database clean and optimized. A bloated database can really slow things down.
- On the flip side, if you have a small site without much content churn, you might be able to get away with emptying trash less often than the default 30 days. It‘s all about balancing safety and performance based on your specific needs.
To give you a concrete example, let‘s say you run a busy news site that publishes 20+ posts per day. With that much content flowing through, it‘s probably a good idea to empty the trash on a daily basis. You could use the Empty Trash Button plugin to set the auto-empty frequency to one day. That way you have a full 24 hour window to recover any accidental deletions, but you‘re not letting thousands of trashed posts pile up over time.
In contrast, if you have a small personal blog that you only post to once or twice a month, the default 30 day trash retention is probably fine. You‘re not generating enough deleted content for it to have a noticeable impact on performance, and the longer restoration window gives you more peace of mind.
When to Clean Out Your Trash Manually
Even if you have the trash auto-emptying on a schedule, it‘s still a good idea to manually clean it out from time to time. After all, you probably don‘t keep your kitchen trash can locked away until collection day – you empty it when it gets full or smelly.
The same concept applies to your WordPress trash. If you‘ve recently done a big round of content pruning or bulk deletion, there‘s no reason to wait around for the auto-empty to kick in. Just head over to the Trash section under Posts or Pages and click "Empty Trash" to clear it out immediately:

Doing this regularly can give a nice performance boost to your site since you‘re freeing up database space and eliminating clutter.
In fact, many managed WordPress hosts like WP Engine and Flywheel will automatically empty your trash on a frequent basis as part of their performance optimization services.
Restoring Content from the Trash
Of course, the whole point of the WordPress trash system is to give you a chance to restore items if you need to. To do that, click on the Trash link for the relevant content type (Posts, Pages, etc.) in your dashboard.
You‘ll see a list of all items currently in the trash. To restore one, simply hover over its title and click the "Restore" link that appears:

The item will be instantly restored to its original location. If you want to put it somewhere else, you can edit the restored item and change its attributes.
One word of caution: Be aware that restoring an item from the trash also restores its original publication date. So if you trash an old post from 2012 and then restore it a few days later, it will be republished with its original 2012 date, not the current date. That can mess up your content freshness and make it look like you‘re publishing ancient content.
If you want the restored item to have a current publication date, you‘ll need to manually edit it and update the publish date after restoring it from the trash. It‘s an extra step, but worth doing to keep your content timeline accurate.
Don‘t Forget About WordPress Revisions
While we‘ve been focusing mainly on the trash system for deleted content, it‘s worth noting that WordPress has a separate system for managing post revisions.
Every time you save a draft or update a published post, WordPress automatically saves a copy of the previous version as a revision. This allows you to go back and restore an earlier version of your content if you need to.
However, just like with trashed content, post revisions can really start to pile up over time, especially on sites with a lot of content updates. According to WordPress.org, "some sites might have a very large number of revisions (thousands). This can slow down queries in the admin area of your site."
To prevent revisions from getting out of hand, WordPress has a few controls in place:
- By default, WordPress only stores a maximum of 25 revisions per post or page. You can change this number by filtering the "wp_revisions_to_keep" hook.
- Revisions are automatically deleted when their parent post or page is deleted (either to trash or permanently).
- There‘s also a handy "wp_revisions_to_keep" setting in wp-config.php that lets you set a sitewide maximum number of revisions.
So if you‘re concerned about the performance impact of too many revisions, you have a few options to keep them under control. Just be aware that revisions are stored separately from trashed posts, so emptying your trash alone won‘t clean out your revisions.
Key Takeaways and Next Steps
Whew! We‘ve covered a lot of ground in this guide to mastering the WordPress trash system. Let‘s recap some of the key points:
- The WordPress trash is a safeguard against accidental content deletion, but relying on it too much can hurt your site‘s performance.
- There are three main ways to control trash behavior: the Empty Trash Button plugin, editing wp-config.php, or custom filter code.
- With great power comes great responsibility. Be very careful about disabling or severely limiting the trash without robust backup systems in place.
- Emptying your trash manually and optimizing your auto-empty frequency can provide a nice performance boost and keep your database tidy.
- Don‘t forget to consider post revisions as you develop your overall content preservation and deletion strategy.
Armed with this knowledge, you‘re ready to take control of your site‘s trash settings and find the right balance of content safety and speedy performance.
Additional Resources
If you want to learn more about WordPress trash, restoration, and database optimization, check out these helpful resources:
- WordPress Codex: Trash
- WordPress Codex: Revisions
- WPBeginner: Beginner‘s Guide to WordPress Database Management
- Kinsta: A Deep Dive Into the WordPress Trash Bin
Now go forth and conquer your trash! And as always, let me know if you have any other questions. I‘m here to help you keep your WordPress site running safe, clean, and fast.
