How to Automatically Empty Trash Daily in WordPress

WordPress Empty Trash Best WordPress Hosting

WordPress is the most popular blogging platform offering flexibility to use it for other kinds of websites as well. There are lots things including Posts, pages media, images and comments. You can also install plugins for more features or use custom code to use WordPress for other things. It also has a recycle-bin like feature called trash. When we delete some posts or comments, it goes to trash instead of being permanently removed. This feature is made to avoid accidentally deletion of an important article.

How To Automatically Empty Trash Daily

If there is not enough protection against SPAMS, you will get many spam comments and posts on your blog. To avoid spam, there are many plugins available. But free plugins do not work as expected. In this case, we have to delete many spam comments and posts which go to trash. But it remains in the database and consume space. So we also need to remove items from trash to free some space.

Read: 10+ WordPress Slider Plugins

There is also a nice option in WordPress by which you can set your blog to delete all items in trash automatically on daily basis. It will reduce your work load.

Follow these steps:

Open wp-config.php file. It will be at the root of your WordPress installation. Now add following code in this file.

If you want to schedule it for week, change 1 to 7. This number is the number of days for which you want to schedule the automatic deletion of trash. If you want to keep posts in trash for next 30 days, you can set the value to 30

Read:

Avoid Duplicate Content Issue By Showing Post Excerpt At Homepage
Broken Link Checker WordPress Plugin: Avoid Broken Links in Blog

advertisement

Leave a Reply

Your email address will not be published. Required fields are marked *