How To Automatically Empty WordPress Trash
When deleting comments, pages, or posts WordPress automatically places them in the “trash” folder.
For specific individual reasons this default WordPress setting may not be suitable for some WordPress users. Some WordPress users prefer comments, pages, and posts to be permanently deleted on a schedule opposed to taking sitting in the Trash waiting to manually be permanently deleted or restored. After all, it is great practice to keep your content management system completely clean and minimal for better optimization and every little piece counts.
Take control of WordPress with simple PHP
Luckily for WordPress users who want their comments, pages, and posts to be permanently deleted without having to go the extra mile each time there is a very simple PHP code snippet, which can easily be customized to schedule permanent deletion of WordPress comment, page, and post trash per day or almost instantaneously.
To use the PHP code, you will need to know how to access your wp-config.php file. The wp-config.php is located at the root of your WordPress install.
How to empty WordPress trash instantaneously
Copy and paste the PHP snippet below into your wp-config.php file
[Normal_Box]
define('EMPTY_TRASH_DAYS', X);
[/Normal_Box]
How to empty WordPress trash on a daily schedule
In the PHP snippet above, change X to the number of your preferred amount of days. For example to make WordPress delete trash each day, change X to 1. Therefore WordPress will delete comment, page, and post trash each 1 day. The PHP is an example of how to empty WordPress trash each 1 day.
[Normal_Box]
define('EMPTY_TRASH_DAYS', 1);
[/Normal_Box]
Keep in mind, the amount of days can be changed to any number.
- cPanel Down Reports Were Linked to CVE-2026-41940 Emergency Patches
- cPanel Down for Some Users After Emergency Authentication Security Update
- Bot Traffic from China Is Spamming the Web
- WPvivid Bug Exposes 900,000 WordPress Sites to Remote Takeover
- WordPress 6.9 Is the Most Problematic Update of All Time
WordPress Bot Protection
Bot Blocker for WordPress
Monitor bot traffic, review live activity, and control AI crawlers, scrapers, scanners, spam bots, and fake trusted bots from one clean WordPress dashboard.
Sean Doyle
Sean is a tech author and security researcher with more than 20 years of experience in cybersecurity, privacy, malware analysis, analytics, and online marketing. He focuses on clear reporting, deep technical investigation, and practical guidance that helps readers stay safe in a fast-moving digital landscape. His work continues to appear in respected publications, including articles written for Private Internet Access. Through Botcrawl and his ongoing cybersecurity coverage, Sean provides trusted insights on data breaches, malware threats, and online safety for individuals and businesses worldwide.







2 Comments
Thank you so much!!
Thanks. Cheers mate!