How to automatically clear WordPress bins
Apr 20, 2025 am 06:09 AMDo you want the junk on your WordPress website to be automatically emptied?
By default, WordPress automatically deletes everything in the trash for 30 days. However, some users may prefer to clear the garbage more or less.
In this article, we will show you how to automatically clear the garbage every day, weekly, or at any time interval you want.
What is garbage in WordPress?
WordPress added the trash function as early as version 2.9. It works like a recycling bin or trash can on a computer.
In other words, the posts you delete are not deleted immediately, but are sent to the trash. Therefore, you can restore them before you permanently delete them after a period of time.
Anyone could accidentally click on the “Delete” link on the post. That's why WordPress can easily recover deleted posts and pages.
Your WordPress website will automatically delete everything in the trash after 30 days so that they don't pile up and continue to use server resources.
If you want to prevent WordPress from automatically clearing the bin, you can follow our guide to how to disable automatic clearing the bin in WordPress.
But what if you want to empty the trash regularly instead of once a month?
Let's see how to automatically clear the trash in WordPress after a while.
We will introduce two methods. You can use the link below to jump to your preferred method:
- Method 1: Use WPCode to automatically clear WordPress trash bin (recommended)
- Method 2: Use plugins to automatically clear WordPress trash
Method 1: Use WPCode to automatically clear WordPress trash bin (recommended)
For this method, we will automatically clear the trash in WordPress using a custom code snippet.
You can add this code snippet to the functions.php file of the WordPress theme. However, a tiny bug in the code can break your website and make it inaccessible.
This is why we recommend using WPCode. It is the best code snippet plugin for WordPress, allowing you to safely add custom code to your website without breaking it.
First, you need to install and activate the free WPCode plugin. For more details, see our WordPress plug-in installation guide.
Note: WPCode also has a paid plan that you can install to unlock amazing features such as code snippet libraries, conditional logic, creating custom blocks, and more.
Once activated, access the Code Snippets ? Add Snippets page from the WordPress Management sidebar.
From here, you have to click the Use Code Snippet button under the "Add Custom Code (New Code Snippet)" option.
This will lead you to the Create Custom Code Snippets page where you can start typing the title of the code snippet. It can be anything that can help you identify it.
After that, select the "PHP Snippet" option as "Code Type" from the drop-down menu on the right.
Next, just copy and paste the following code into the Code Preview box:
However, if you set the number of days to 0, the WordPress trash feature will be completely removed. WordPress will then permanently delete posts and pages without putting them in the trash.
Note: Before activating this feature, make sure to back up your WordPress site so that you can recover any accidentally deleted pages or posts.
Next, scroll down to the Insert section and select “Auto Insert” mode. Now, as long as you save the code snippet, the custom code will take effect on your website.
After that, scroll to the top of the page and switch the Inactive switch to Active.
Finally, don't forget to click the "Save Fragment" button to store your settings and execute code on your website.
Method 2: Use plugins to automatically clear WordPress trash
If you don't want to add code to your website, this method is for you.
First, you need to install and activate the Change Empty Junk Time plugin. For more details, see our step-by-step guide on how to install WordPress plug-ins.
Once activated, go to the Settings ? General page from the WordPress admin area.
Once there, scroll down to the bottom of the page where you will find the new "Time to Empty Trash" option.
Here, just enter the number of days it takes for WordPress to empty the bin. For example, you can type 1 for daily, 7 for weekly, or 30 for monthly.
If you enter 0, deleted posts and pages will be permanently deleted instead of being placed in the trash.
Note : Be very careful when setting the clear time to 0. Recovering permanently deleted posts and pages can be difficult. Make sure you use the backup plugin just in case. To do this, we recommend using a replicator.
When you are done, don't forget to click the "Save Changes" button to store your settings.
We hope this tutorial helps you understand how to automatically clear the trash in WordPress. You may also want to learn how to get a free SSL certificate or view a list of the best WooCommerce plugins for your online store.
The above is the detailed content of How to automatically clear WordPress bins. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP does not directly perform AI image processing, but integrates through APIs, because it is good at web development rather than computing-intensive tasks. API integration can achieve professional division of labor, reduce costs, and improve efficiency; 2. Integrating key technologies include using Guzzle or cURL to send HTTP requests, JSON data encoding and decoding, API key security authentication, asynchronous queue processing time-consuming tasks, robust error handling and retry mechanism, image storage and display; 3. Common challenges include API cost out of control, uncontrollable generation results, poor user experience, security risks and difficult data management. The response strategies are setting user quotas and caches, providing propt guidance and multi-picture selection, asynchronous notifications and progress prompts, key environment variable storage and content audit, and cloud storage.

The real use of battle royale in the dual currency system has not yet happened. Conclusion In August 2023, the MakerDAO ecological lending protocol Spark gave an annualized return of $DAI8%. Then Sun Chi entered in batches, investing a total of 230,000 $stETH, accounting for more than 15% of Spark's deposits, forcing MakerDAO to make an emergency proposal to lower the interest rate to 5%. MakerDAO's original intention was to "subsidize" the usage rate of $DAI, almost becoming Justin Sun's Solo Yield. July 2025, Ethe

Directory What is Bitcoin? How does Bitcoin work? Why is Bitcoin not scalable? What is BIP (Bitcoin Improvement Proposal)? What is Bitcoin Taproot Update? Pay to Taproot (P2TR): Benefits of Taproot: Space-saving privacy advantages Security upgrade conclusion: ?Bitcoin is the first digital currency that can send and receive funds without using a third party. Since Bitcoin is software, like any other software, it needs updates and bug fixes. Bitcoin Taproot is such an update that introduces new features to Bitcoin. Cryptocurrency is a hot topic now. People have been talking about it for years, but now with prices rising rapidly, suddenly everyone decides to join and invest in them. Message

Domestic purchase of Bitcoin must be carried out through compliance channels, such as Hong Kong licensed exchanges or international compliance platforms; 2. Complete real-name authentication after registration, submit ID documents and address proof and perform facial recognition; 3. Prepare legal currency and recharge it to the trading account through bank transfer or electronic payment; 4. Log in to the platform to select Bitcoin trading pairs, set limit orders or market orders to complete the transaction; 5. Pay attention to market fluctuations and platform security, enable dual certification and comply with domestic regulatory policies; overall, investors should operate cautiously under the premise of compliance and participate in Bitcoin investment rationally.

What is Treehouse(TREE)? How does Treehouse (TREE) work? Treehouse Products tETHDOR - Decentralized Quotation Rate GoNuts Points System Treehouse Highlights TREE Tokens and Token Economics Overview of the Third Quarter of 2025 Roadmap Development Team, Investors and Partners Treehouse Founding Team Investment Fund Partner Summary As DeFi continues to expand, the demand for fixed income products is growing, and its role is similar to the role of bonds in traditional financial markets. However, building on blockchain
![[2025 Latest] Bitcoin real-time market APP rankings, these 5 are the most accurate and fastest!](https://img.php.cn/upload/article/000/000/083/6888925c6d544409.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
The five most popular Bitcoin market APPs in 2025 are: 1. Binance, whose data comes directly from the world's largest trading pool, updated in milliseconds, suitable for professional traders; 2. Ouyi (OKX), accurate market conditions and smooth APP experience, the first choice for mobile users; 3. Huobi (HTX), a veteran exchange, stable technology, reliable mainstream currency data; 4. Gate.io (Sesame Open Door), rich currency types, is a powerful tool for mining the early market of altcoins; 5. CoinMarketCap, a world-renowned data aggregation platform, integrates data from hundreds of exchanges, provides weighted average reference prices, authoritative and fair.

The total amount of Bitcoin is 21 million, which is an unchangeable rule determined by algorithm design. 1. Through the proof of work mechanism and the issuance rule of half of every 210,000 blocks, the issuance of new coins decreased exponentially, and the additional issuance was finally stopped around 2140. 2. The total amount of 21 million is derived from summing the equal-scale sequence. The initial reward is 50 bitcoins. After each halving, the sum of the sum converges to 21 million. It is solidified by the code and cannot be tampered with. 3. Since its birth in 2009, all four halving events have significantly driven prices, verified the effectiveness of the scarcity mechanism and formed a global consensus. 4. Fixed total gives Bitcoin anti-inflation and digital yellow metallicity, with its market value exceeding US$2.1 trillion in 2025, becoming the fifth largest capital in the world

This article explores in-depth two main strategies for implementing call hold (Hold) and recovery (Un-hold) in Twilio voice calls. First of all, it is recommended to use the Twilio Conference feature to easily control the retention and recovery of calls by updating the resources of meeting participants, and to configure the retention of music. Second, for more complex independent call leg scenarios, the article explains how to manage call state through carefully designed TwiML streams (such as using, and) to avoid accidental disconnection of non-holding legs and enable call reconnection.
