Hey WordPress user! Are you tired of your trash folder filling up with old posts and pages? Want to keep your database lean and mean? You‘re in the right place.
In this ultimate guide, I‘ll show you exactly how to take control of your WordPress trash emptying schedule. Whether you want to clear it out daily, weekly, or even disable the trash entirely, you‘ll learn how to do it quickly and safely.
What is the WordPress Trash?
First, let‘s make sure we‘re on the same page about the WordPress trash feature. When you delete a post, page, or comment on your site, WordPress doesn‘t actually delete it right away. Instead, it sends it to the trash folder, kind of like the Recycle Bin on your computer.
By default, anything in the trash will sit there for 30 days. After that, poof, WordPress deletes it automatically. This gives you a nice 30-day window to restore something if you deleted it by accident.
Why Empty the Trash?
"But wait," you might be thinking, "if WordPress empties the trash automatically after 30 days, why would I need to change that?"
Good question! There are a few reasons you might want to customize your trash emptying schedule:
Save database space: Every post, page, and comment in your trash takes up space in your WordPress database. For busy sites, trash can pile up fast and start hogging resources. Emptying trash more often keeps things running lean.
Declutter your admin area: Seeing a huge number next to "Trash" in your dashboard menu is just plain annoying. If digital clutter stresses you out, you can empty the trash more frequently for a tidier admin experience.
Keep content around longer: On the flip side, you might want to keep deleted content for more than 30 days. Maybe you have multiple authors and want more time to catch accidental deletions. Extending the trash window gives you extra peace of mind.
Comply with retention policies: Some industries have strict rules around how long certain types of data can be retained. If you‘re subject to these, you may need to delete trash on a specific timeline to stay compliant.
So, ready to customize your trash settings? Let‘s look at a couple ways to do it.
Change Trash Settings with Code (Functions.php)
If you‘re comfortable adding a bit of code to your WordPress site, you can adjust your trash emptying schedule by adding a snippet to your theme‘s functions.php file or a site-specific plugin.
Here‘s how:
- Access your WordPress files via FTP/SFTP or your hosting control panel‘s file manager.
- Navigate to your current theme‘s folder (usually
/wp-content/themes/your-theme/). - Look for the
functions.phpfile and download a copy to your computer as a backup. - Open the
functions.phpfile in a text editor. - Add this code snippet at the end of the file:
function custom_trash_schedule() {
define(‘EMPTY_TRASH_DAYS‘, 10 );
}
add_action(‘init‘, ‘custom_trash_schedule‘);In this snippet, you‘ll change the number 10 to the number of days you want WordPress to wait before emptying the trash. For example, you could use:
1to empty the trash every day7to empty the trash every week0to disable trash and delete permanently (use with caution!)
- Save your changes and re-upload the
functions.phpfile.
That‘s it! Your new custom trash schedule will take effect immediately.
Using a Site-Specific Plugin
If you‘re nervous about editing your theme files directly, you can achieve the same result with a site-specific plugin. This lets you add custom code snippets without risking breaking your theme.
To create a site-specific plugin:
- Connect to your WordPress site via FTP/SFTP or your hosting file manager.
- Navigate to the
/wp-content/plugins/folder. - Create a new folder and name it something like
custom-functions. - Inside that new folder, create a file called
custom-functions.php. - Open the
custom-functions.phpfile in a text editor. - At the top of the file, add this PHP comment block:
<?php
/*
Plugin Name: Custom Functions
Plugin URI: https://yoursite.com/
Description: Site-specific functions and code snippets
Author: Your Name
Version: 1.0
*/- Below that comment block, paste in the same trash emptying snippet from above.
- Save the file and re-upload it to your
/custom-functions/plugin folder. - In your WordPress dashboard, go to Plugins and activate the new "Custom Functions" plugin.
Voila! You‘ve now adjusted your trash schedule with a site-specific plugin.
Change Trash Settings with a Plugin
Not keen on messing with code? No problem. There are several handy (and free!) plugins that add a user-friendly interface for changing your WordPress trash settings. Here are a couple of my favorites:
1. Optimize Database after Deleting Revisions
The Optimize Database after Deleting Revisions plugin does way more than just empty trash. It adds a whole suite of database optimization tools to your WordPress admin area.
With this plugin, you can:
- Change trash emptying schedule (days)
- Manually clear trash
- Optimize database tables
- Remove old post revisions and auto-drafts
Once you‘ve installed the plugin, you‘ll see a new "Optimize DB" menu item under Tools in your WordPress dashboard. From there, you can set your desired trash retention in the "Settings" tab:

The interface even shows you a snapshot of how much database space various old data types are taking up, so you can make informed decisions.
2. WP-DBManager
Another great choice is WP-DBManager. Along with trash emptying controls, it adds other useful database utilities like:
- One-click database backups
- Database restore from backup
- Repair and optimize database tables
- Run SQL queries
Once installed, you‘ll see a new "WP-DBManager" admin menu item. Click "Empty/Vacuum Tables" then set your desired trash retention in the "Empty Trash" field:

The plugin will show you a list of your database tables along with how much space they‘re taking up. Tables with inactive items like the trash are helpfully colored red.
Important Notes
Messing with WordPress trash settings is pretty low-risk, but there are a few important things to remember:
Always backup first! Before tweaking trash settings or running any database optimization, make sure you have a current backup. I like to make a manual database backup (via phpMyAdmin) and a full site backup (with a plugin like UpdraftPlus) just to be safe.
Communicate with your team: If you‘re not the only one publishing content on your site, let your contributors know before changing trash settings. You don‘t want someone counting on the default 30-day retention only to have their deleted content disappear much sooner!
"Zero days" disables trash entirely: If you set your trash emptying schedule to zero days, WordPress will skip the trash and delete posts/pages/comments immediately and permanently. Only use this setting if you‘re very confident you won‘t need to restore deleted content.
Schedule optimization during low-traffic periods: Clearing out old trash items and optimizing your database tables is a resource-intensive process. Try to schedule these tasks during off-peak hours to minimize impact to your visitors.
WordPress Trash FAQs
Still have questions about the WordPress trash feature? Here are answers to some of the most common ones I hear:
Can I restore content after I empty the trash?
Unfortunately, once you click "Empty Trash" or content is auto-deleted according to your schedule, it‘s gone forever. That‘s why backups are so crucial! With a backup in hand, you can restore your entire site to a point before you emptied the trash.
Does emptying trash improve WordPress performance?
It can, especially if your trash has been piling up for a while. Every post or page in the trash is still taking up database space, so clearing them out frees up those resources.
The performance impact depends a lot on your unique situation. Let‘s look at some quick numbers:
| Scenario | Database Size | Trash Size | Percent Bloat |
|---|---|---|---|
| Small blog, 50 posts, trash for 1 month | 25 MB | 2 MB | 8% |
| Busy news site, 5K posts, trash for 1 year | 750 MB | 150 MB | 20% |
| E-commerce site, 10K orders, trash for 6 months | 2 GB | 500 MB | 25% |
As you can see, the longer you let trash build up, the bigger percentage of your database it will consume. Emptying trash frees up that space for better performance.
What happens to media attachments in the trash?
When you delete a post or page that contains images or other media attachments, only the post/page itself moves to the trash. The associated media files stay in your media library.
So even if you empty the trash, deleting the post or page, those media attachments will still remain. If you want to clean them up too, you‘ll need to delete them separately via the Media section of your dashboard.
One quick way to find "unattached" media files is to use a plugin like Media Cleaner. It scans your media library and shows you files that aren‘t associated with any active posts or pages.
Does changing trash settings affect old trash content?
Yes. When you change your trash emptying schedule, it takes effect immediately on all trashed content.
For example, let‘s say you have 3 posts in the trash, one from 5 days ago, one from 20 days ago, and one from 45 days ago. If you change your trash setting from 30 days to 10 days, the 20-day-old and 45-day-old posts will be deleted immediately. The 5-day-old post will stick around for 5 more days, then be deleted on the new schedule.
So it‘s a good idea to check your trash contents before making big changes to the schedule!
Putting it All Together
There you have it, the complete guide to mastering your WordPress trash settings. Let‘s recap the key points:
- WordPress trash is a safeguard to store deleted posts, pages, and comments for 30 days
- You can customize the trash retention schedule by editing the
functions.phpfile or using a plugin - Emptying trash more often can improve site performance and clear clutter
- Use trash settings carefully, always back up your site, and communicate changes to your team
- When in doubt, leave the default 30 day schedule alone!
Armed with this knowledge, you‘re now ready to optimize your WordPress trash settings for your unique needs.
So go ahead, take out the trash with confidence. Your WordPress site will thank you!
