Featured templates

How to limit or disable automatic empty trash in WordPress

Carey Burns January 12, 2018
Rating: 5.0. From 2 votes.
Please wait...

Our support team is ready to present you a new tutorial that shows how to limit or disable the automatic empty trash in WordPress.

When you delete a post or comment in WordPress, it is placed to the trash by default. Trashed posts and comments remain in your database for 30 days. In case it is needed you can restore anything from the trash.

After 30 days, WordPress automatically deletes all trash content permanently.

In this article, we will explain how to limit or disable automatic WordPress empty trash feature.

  1. If you would like WordPress to stop deleting the items from trash automatically, open file functions.php located in the theme folder. Add the following code to the file:
    function my_remove_schedule_delete() {
        remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
    add_action( 'init', 'my_remove_schedule_delete' );

    Now, when you send an item to the trash, it will remain there until you go to the trash and empty it manually.

  2. WordPress automatically empties trash after 30 days. You can change this to any number of days you want. In order to do so, you need to add the following line to wp-config.php file, located in the root folder of your site:
    define('EMPTY_TRASH_DAYS', 7);
    You can change 7 to any other number of days.

Feel free to visit our blog to check more tips on working with WordPress templates. Stay tuned!

Premium Wordpress Templates
This entry was posted in Monstroid Tutorials, WordPress Tutorials and tagged empty, limit, trash. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket