Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Trash status

This article is marked as in need of editing. You can help Codex by editing it.

Description

The Trash is a place to put something that you no longer want such as obsolete posts, or unwanted comments. If you click 'Trash' for any item, it will be sent to the trash. Once an item is placed into the Trash, it remains there for 30 days (by default) before being permanently deleted. You can also choose to permanently delete items from the Trash at any time. Once an item has been permanently deleted, it is gone forever.

Send to Trash

At the post/page/comment edit list page, click the 'Trash' quick link below the item to send it to the trash. From the Add new Post/Page, you can click 'Move to Trash' next to the 'Publish' button. From the Edit Post/Page, you can click 'Move to Trash' next to the 'Update' button.

Restore from the Trash

From the post/page/comment edit list page, 'Trash' is one of the view options. (Sometimes it only appears if there are Trashed items.) When you click to see the 'Trash' view, the list will be filtered to show only items in the Trash. A 'Restore' quicklink is shown below each item, you can restore the item from the Trash by clicking this link. Alternatively you can bulk-restore by selecting items with the checkbox and choosing the restore option from the pull-down menu.

Delete Permanently

When you click the 'Trash' link, the trashed items are on the list. Click the 'Delete Permanently' link below each item to remove an item forever. Alternatively you can bulk-delete with the checkboxes and pull-down menu.

Default Days before Permanently Deleted

By default, posts, pages or comments in the trash will be permanently deleted after 30 days.

(Each item will be deleted 30 days after it is sent to the trash. If you trash things at different times, you may find some items are deleted and some remain.)

EMPTY_TRASH_DAYS option

There is a constant that can be set in your wp-config.php file:

define('EMPTY_TRASH_DAYS', 30);

   * (int) >= 0 : the length of days before items are permanently deleted. Default : 30

Note: If this constant is set to 0, the trash functionality will be disabled and the 'Delete Permanently' button will appear instead of 'Trash' button. If you click 'Delete Permanently' button, the item will immediately be deleted without any alert message.

Functions

In WordPress 2.9.0, a get_delete_post_link() function was added that can be used within a plugin to move a post to the trash.