This article of wpexpelor is about wordpress trash location. You may have come across the question: where the things that we delete on our WordPress website is saved? And whether it is possible to restore deleted items or not? How can I restore deleted post and pages in WordPress? Here, we are going to explain the answer.
WordPress trash location for Deleted posts and pages
When you delete a “post” in wordpress, it goes to the trash section. It is easy to access the trash location, just open all posts section from the WordPress dashboard. Then go to the trash tab, and the contents that we have deleted can be found there.
It is the same with the “pages”. You can find the deleted items by clicking on the all pages section, and there is a trash section there that belongs to the deleted page this time.
By clicking on Restore, you can restore the items (whether it is a post or a page)
What happens when we delete a post(page) in wordpress?
When we delete the page/post, the WordPress content management system labels the items as “temporarily deleted”. By this, it informs the database that this item has been deleted and is in the Trash. By default, WordPress content and pages are located in the “wp_posts” table of the database.
As you can see in the image below, there is a column named “post_status” in this table. This column shows the status of each post.
Now, we are going to check the trash status through an SQL query. Open the “wp_posts” table and click on SQL to write this query:
SELECT * FROM wp_posts WHERE post_status = 'trash';
This query means showing all the contents that the “post_status” is set on “trash.”Click on the “GO” button to show the result.
Here is the result:
Limit or disable automatic empty trash wordpress
The WordPress Trash can keep deleted content for 30 days by default, and after 30 days, it deletes everything forever.
You can not restore the content that is permanently deleted unless you have a backup from the website. If you want to limit or disable automatic empty trash wordpress and change the amount of storage in the Trash, you can use the following piece of code:
define('EMPTY_TRASH_DAYS', 7);
Place the code in the “wp-config.php” file.
In the code above, we put the value 7. This means that after 7 days, the Trash will be emptied automatically. As we said, the default value is 30 days so that you can increase or decrease this value according to your needs.
Restore deleted wordpress Comments
Restoring WordPress comments is the same as the procedure that we explained for deleted posts and pages. Open the comments section from the WordPress dashboard, and then you can restore any comments from the trash section.
The only difference is that the comment table is stored in a different table in the database. In fact, the comments are placed in the “wp_comments” table in the database.
Restore deleted media in wordpress
WordPress media section does not have a trash section! So when you decide to delete media, make sure! Because it’ll be deleted permanently and can’t be restored. But Is it possible to restore deleted media in wordpress?
As I said, the WordPress content management system doesn’t support such a possibility by default, but you can use plugins to restore images as well. To do so:
- Open the WordPress dashboard and then go to the Plugins section.
- Search for “Media Trash Button” and install and activate the plugin.
- Open the media section.
As you can see, a notification appears at the top of the page that tells you to copy this piece of code and place it in the “wp-config.php” file.
define('MEDIA_TRASH', true);
Open the file manager via FTP or open your site’s hosting panel, edit the “wp-config.php” file, and add the piece of code to it.
By clicking this option, our media will be moved to the Trash.To access the Trash can, click on All media items and select Trash.In this section, you can see and manage your deleted media.
I hope this article of wpexpelor about wordpress trash location was handy for you. Comment with any questions below. Best