Take Out The New Year’s Trash

This post contains a Tutorial with basic programming skills and requires FTP root access.

With the release of WordPress 2.9 comes one of the best additions to the core functionality, the TRASH function. Basically an “un-delete” option, the WordPress Trash function makes it almost impossible to accidentally delete a page, post or comment.

By default, anything ‘thrown’ into the trash will be deleted automatically after 30 days. You can also manually delete anything in the trash by clicking the ‘permanently delete’ link from inside the trash bin, so to speak.

Fortunately, WordPress has add the ability to change the number of days you want to store the trash before automatic deletion. This can be a very good thing for several reasons.

First, should you decide you want to use the trash as a ‘storage bin’ of sorts, to get rid of some older pages or posts that you don’t have live on the site, but want to keep for possible future use should you need too, and not have them clutter up your page, post or comment list.

Second, it makes it useful for those that really do what to get rid of those unwanted items but feel a little hesitant to just delete them and have them disappear immediately into nowhere land, just to realize you probably really didn’t want to delete it in the first place because you needed something out of one of them – it can give them a few extra days to see if they really DID need anything.

As I used to always tell my clients, turn it to a draft instead of deleting it right away (in the case of pages or posts). Then, if you find you really didn’t need it after a week, delete it. If you did need it, then you have it, because once you delete it, it is gone forever! Well, the trash function eliminates that. Trash it, then if you need it, restore it. If not, it will delete on its own after a period of time.

Third, adjusting the days and item is in the trash can make it useful to those that do not want a trash feature. Although, in honesty, I am not sure exactly why you wouldn’t want a little extra reassurance that you won’t ever accidentally delete something – but I guess people are as different as rocks, they all look like rocks on the surface, but inside some contain the most beautiful things – while others have just more dense rock. But – the option is there should you chose it.

The ONLY bad thing about this in my opinion, is that WordPress didn’t make this an option in the settings – exactly why, I’m not sure. They didn’t even make it so the function is ‘hook-able’, so that a plugin could be created to give the option to the user. Instead, you have to do a little work to change them and for a non-programmer, this can be a bit of a daunting task.

I decided to show anyone interested, how to do change the number of days the trash is stored. Not everyone will be able to make this adjustment, but those of you that can, it may be helpful. Maybe WordPress will add this as an option in the near future.

  • First and foremost, you  will need to have access to your Root WordPress Directory via some sort of FTP method or File Manager (via your hosts control panel). There is no getting around that.  And READ the rest of these steps BEFORE you start any of them. It is better to know what you’re getting into before you are in the middle of it and realize you can’t do it.
  • Next, you will be editing the wp-config.php file which is in the root WordPress Folder. So once you locate that, download a copy of it, or open it in your File Manager editor.
  • MAKE A COPY of the file. Do NOT edit in it directly unless you know that you won’t screw it up. That way, should anything go wrong, you can just re-upload or re-activate the original and no harm done. If you don’t make a copy of the file, don’t blame me when you screw up your site – because I told you so.
  • When you have the copy of the file, open it up. It’s not a very large file, but it holds all the information for your database connection and some other settings. You need to find the part right after it says define ('WPLANG', '');
  • Add this line after that:
    define('EMPTY_TRASH_DAYS', 30 );
  • The 30 is the number of days that the trash is saved before automatically emptying it. Change the 30 to whatever number you want – if you want to keep the trash for six months, enter 180, if you only want it to save for a week, enter 7. Should you decide you do not want the Trash function at all, enter 0.
  • Check to make sure you did not enter any stray characters. Also check to make sure your single quotes around the EMPTY_TRASH_DAYS are straight up single quotes. If you have a ‘curly’ quote or any other ‘magic’ type quote, change it to a single quote (right next to the ENTER key). Then, save the file.
  • Upload the file back to the correct folder (for FTP) or save it if using a File Manager.

You should now have your trash settings set the way you want them. Remember – you’re in control!
Happy Trashing!



One Response to “Take Out The New Year’s Trash”

  1. Ruby Krikwen says:

    I would like to begin by saying, thank you for supplying me with the information I’ve been looking for. I’ve been searching the internet for three hours looking for it and wish I would have located your website sooner. Not only did I locate what I was searching for, but also found answers to questions I never thought to ask. Thank you for your wonderful web-site!

Leave a Reply