How to Automatically Empty Your Trash in WordPress [Quick Tips]

In WordPress, there is this “Trash” feature that keep your deleted articles (and comments) in the recycle bin until you go into the bin and delete them permanently. This is an useful feature as it prevents you from deleting any posts/comments accidentally. However, if you don’t have the habit of clearing your trash regularly, it would pile up with useless articles, which in turn translate to bigger database size and slower site loading.

Here’s a quick and simple way to configure your WordPress to automatically clear the trash on a regular basis:

1. Using a FTP application (such as Filezilla), download the wp-config.php file from your server.

2. Open the wp-config.php file with a text editor and insert the following code to the end of the file:

define('EMPTY_TRASH_DAYS', X );

where ‘X’ is the interval (in days) the trash will auto-empty itself.

For example, if you want the trash to auto-empty itself every 7 days, the code will be

define('EMPTY_TRASH_DAYS', 7 );

Disable the trash feature

In some cases, you might want to disable the trash feature altogether. You can do this by setting the number of day to 0. The code become:

define('EMPTY_TRASH_DAYS', 0 );

That’s it.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Damien Oh Avatar

Read next

Content and cloud networks now account for three-quarters of used international bandwidth, while Google, Meta, Microsoft and Amazon own, co-own or buy capacity on a growing share of the 600-plus submarine cable systems carrying over 99 per cent of data between countries, a private map hidden below the wireless internet
Wi-Fi doesn’t actually slow down when a café gets crowded — the signal is fine, but every device has to wait its turn to speak on the same frequency, and the polite queuing is what you feel as lag
In 1988, a 23-year-old Cornell graduate student named Robert Morris released a self-replicating program to measure the size of the internet — within hours it had crashed roughly 6,000 of the 60,000 machines then online, and computer security became a field
In July 2026, Psy’s Gangnam Style passed six billion YouTube views, fourteen years after its horse-riding dance became the platform’s first billion-view video and long after engineers had replaced a counter designed to stop at 2,147,483,647
Suzanne Simard sealed paper birch and Douglas fir seedlings inside plastic bags, fed them carbon-14 and carbon-13 dioxide, and nine days later found carbon had crossed between species through fungal threads in the British Columbia soil beneath her boots
A species of jellyfish called Turritopsis dohrnii can revert its adult cells back to a juvenile polyp stage when injured or starving, effectively restarting its life cycle, and biologists have so far failed to identify any natural limit to how many times it can do this.
A Japanese man named Jiroemon Kimura, who lived to 116, was born in 1897 when Queen Victoria still ruled and died in 2013, meaning a single human life personally overlapped with the invention of the airplane, the atomic bomb, the internet, and Instagram
The Hollywood sign originally read HOLLYWOODLAND when it was built in 1923 as a real estate advertisement for a housing development, and it was only meant to stand for 18 months, but nobody ever got around to taking it down and the city eventually adopted it as a landmark