How to Schedule Empty Trash Automatically in WordPress?

Code Snippet Purpose

When you delete a post or page, WordPress by default send the content to trash section without any warning. However, the trash content will be there forever on your site unless you manually delete them. The purpose of this code snippet is to schedule a automatic job to empty the trash periodically to save your time.

Template to Edit

You have to insert the code snippet in config.php file.

Code Snippet

define('EMPTY_TRASH_DAYS', 5 ); 

Replace 5 days to any number you want to schedule the cleanup job as per your need.

Leave a Comment