How to Stop WordPress from Automatically Emptying Trash

In our previous WordPress tutorial, we guided you to automatically empty your WordPress Trash on daily, weekly, monthly basis, as well as to disable the feature permanently. However, some of you may want to stop WordPress from automatically emptying your trash. If you are those who want to stop that menace, here is what you need to do.

Before that, we just want to let you know that this feature called “Trash” was added to the core since 2.9 version. It is similar to the recycle bin of your local windows computer. It stores all the deleted pages, posts and comments that remain in your database for the next 30 days.

All right, Let’s go and access your file directory using FTP clients or through CPanel. Now go to your theme directory and search for the function.php file. Open that file in edit mode and simply add the following code to the file.

function wpb_remove_schedule_delete() {

    remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );

}

add_action( 'init', 'wpb_remove_schedule_delete' );

The above code will remove the action that deletes trashed items. From now onwards, whenever you will delete the page, post or comment, it will remain there in trash until you go to trash and manually empty it.

We believe this tutorial has helped you to stop WordPress from automatically emptying trash. If you liked our article, please do share this over social media and spread the word. This will help us to reach out to more users like you.

SEE ALSO: How to replace with custom logo and URL on the WordPress login page

Leave a comment