brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: EMPTY_TRASH_DAYS decides how long WordPress keeps your trash

WordPress
~/tips/tip-wordpress-empty-trash-days

define( 'EMPTY_TRASH_DAYS', 60 ); // 60 days

Sets after how many days WordPress permanently deletes trashed posts, pages and comments.

Trashed posts in WordPress do not stay there forever. After 30 days they are deleted for good. One constant changes that number.

define( 'EMPTY_TRASH_DAYS', 60 ); // 60 days

The docs say it sets the number of days before WordPress permanently deletes posts, pages, attachments and comments from the trash, and that the default is 30 days.

Why change it? On a site with several authors, 30 days can be short: somebody trashes a page before a holiday and wants it back after. A longer window costs a bit of database space and nothing else. On a site where you clean up a lot, a shorter window keeps the tables tidier.

You can also turn the trash off:

define( 'EMPTY_TRASH_DAYS', 0 ); // Zero days

I would not. The docs add that with this setting WordPress does not ask for confirmation when someone clicks “Delete Permanently”. One slip and the post is gone.

Caveat: the trash is not a backup. Anything deleted for good, by the timer or by hand, only comes back from a real backup of the database. And the constant goes in wp-config.php above the line that says to stop editing, or WordPress will not pick it up.

Further reading: WordPress: editing wp-config.php, On this site: AUTOSAVE_INTERVAL changes how often WordPress autosaves

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link