Post Pic

WordPress tip: Automatically empty Trash

Trash is a new functionality from WordPress 2.9. When an item (post, comment, etc) is deleted, it goes in Trash instead of being permanently removed. Here is a tip to tell your WordPress blog to autmatically empty trash every X days.

Simply open your wp-config.php file (located at the root of your WOrdPress install) and paste the following code:

define('EMPTY_TRASH_DAYS', 10 );

The second parameter is when to empty trash, in days.

13 Responses

May 20 2010 09:36

That’s a simple trick. Thanks.

May 20 2010 11:35

Ohh superb yar.., nice trick thanks.

Keep rocking.

May 20 2010 19:21

Very useful trick! I’m always forgetting to delete trashed items.

May 20 2010 23:37

thanks for sharing this tip..

May 24 2010 07:36

Thanks for this tip, I have just added it to my config file. Will check up on the next few days.

May 27 2010 01:55

This code will speed up your website a tiny bit. Sometimes, I have up to 100 files in my trash (posts, pages, comments, etc), so it slows things down a tad. Deleting automatically will save space without any effort! Great find! :D

May 29 2010 17:34

Nice tip, thanks!

May 31 2010 22:08

Thanks for the tip, what about repairing the database automatically :
define(‘WP_ALLOW_REPAIR’, TRUE); also in wp-config.php

Jun 02 2010 21:19

Nice tips, thanks!
Is it possible to do the same with spams ? automaticaly delete them after X days ?

Jul 06 2010 16:53

thanks very much this is very useful to me

Jul 20 2010 16:17

Silly question but … can I just add it to anywhere on
wp-config.php
?

Aug 02 2010 16:30

So simple and nice :) . I guess it done with cron jobs that are so awesome :)

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required