Skip links

How to Automatically Empty Trash posts in WordPress

WordPress has Trash feature where was a place to put something that you no longer want such posts, pages and comments. If you click ‘Trash’ it will be sent the item to the trash. and it remains there for 30 days (by default) before being permanently deleted.

This code snippet will let you delete trash by WordPress built-in constant.

Steps to automatically empty trash in WordPress:

  1. Open wp-config.php file, if you work localhost open the same file using any code editor IDE
  2. Add the following code at the bottom of the file.
  3. Save the changes.

[php]
define(‘EMPTY_TRASH_DAYS’, 3 );
[/php]

Did you find the WordPress snippets in this article helpful? Share it with your friends and if you have any questions and want to ask us about it, please don’t hesitate to add comments.

Leave a comment

Explore
Drag