Table of Contents
What is garbage in WordPress?
Method 1: Use WPCode to automatically clear WordPress trash bin (recommended)
Method 2: Use plugins to automatically clear WordPress trash
Home CMS Tutorial WordPress How to automatically clear WordPress bins

How to automatically clear WordPress bins

Apr 20, 2025 am 06:09 AM
wordpress Why 2025

Do 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.

How to automatically clear WordPress bins

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.

How to automatically clear WordPress bins

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

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.

How to automatically clear WordPress bins

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.

How to automatically clear WordPress bins

Next, just copy and paste the following code into the Code Preview box:

How to automatically clear WordPress bins

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.

How to automatically clear WordPress bins

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.

How to automatically clear WordPress bins

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.

How to automatically clear WordPress bins

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

WorldCoin (WLD) price forecast 2025-2031: Will WLD reach USD 4 by 2031? WorldCoin (WLD) price forecast 2025-2031: Will WLD reach USD 4 by 2031? Apr 21, 2025 pm 02:42 PM

WorldCoin (WLD) stands out in the cryptocurrency market with its unique biometric verification and privacy protection mechanisms, attracting the attention of many investors. WLD has performed outstandingly among altcoins with its innovative technologies, especially in combination with OpenAI artificial intelligence technology. But how will the digital assets behave in the next few years? Let's predict the future price of WLD together. The 2025 WLD price forecast is expected to achieve significant growth in WLD in 2025. Market analysis shows that the average WLD price may reach $1.31, with a maximum of $1.36. However, in a bear market, the price may fall to around $0.55. This growth expectation is mainly due to WorldCoin2.

Litecoin (LTC) price drops sharply to $65 Litecoin (LTC) price drops sharply to $65 Apr 21, 2025 pm 06:15 PM

Litecoin (LTC) price plummeted to $65 in early April, down nearly 7.5% in a week, echoing the plunge in the wider cryptocurrency market. The market crash caused billions of dollars to evaporate market value, Bitcoin (BTC) fell below $75,000, and altcoins generally fell. Macro factors such as rising U.S. Treasury yields and expected interest rates appear to intensify risk aversion in global markets. In addition, the large outflow of funds from Bitcoin spot ETFs further hits the confidence of retail investors and institutional investors. Against this backdrop, Litecoin is once again facing its long-term resistance level - the 200-week exponential moving average (EMA). The EMA had suppressed LTC prices in July 2023, when the price was close to $88. Historically, LTC and the

Ranking of legal platform apps for virtual currency trading Ranking of legal platform apps for virtual currency trading Apr 21, 2025 am 09:27 AM

This article lists the ranking of APPs for legal platforms for virtual currency transactions, emphasizing that compliance is an important consideration for choosing a platform. The article recommends platforms such as Coinbase, Gemini, and Kraken, and reminds investors to study regulatory information and pay attention to security records when making choices. At the same time, the article emphasizes that virtual currency transactions are high-risk and investments should be cautious.

What does cross-chain transaction mean? What are the cross-chain transactions? What does cross-chain transaction mean? What are the cross-chain transactions? Apr 21, 2025 pm 11:39 PM

Exchanges that support cross-chain transactions: 1. Binance, 2. Uniswap, 3. SushiSwap, 4. Curve Finance, 5. Thorchain, 6. 1inch Exchange, 7. DLN Trade, these platforms support multi-chain asset transactions through various technologies.

Bitcoin market trend chart in the past decade (analysis of Bitcoin price historical trends from 2014 to 2025) Bitcoin market trend chart in the past decade (analysis of Bitcoin price historical trends from 2014 to 2025) Apr 21, 2025 pm 07:30 PM

Bitcoin price has experienced multiple cycles of fluctuations and growth. 1. From 2013 to 2014, the price soared from less than $10 to $1,150, and then plummeted to $200. 2. From 2015 to 2016, prices stabilized and rebounded, and infrastructure improvements enhanced market confidence. 3. From 2017 to 2018, the price plummeted to US$3,000 after exceeding US$20,000, and the tightening of China's regulatory policies caused an impact. 4. From 2019 to 2021, the price rebounded to more than US$10,000, and exceeded US$60,000 in 2021, and institutional investors entered the market to drive the rise. 5. From 2022 to 2024, the price rebounded to $50,000 after the market correction, and the launch of US ETFs brought new funds. 6. At the beginning of 2025, the price is around 1

How to win KERNEL airdrop rewards on Binance Full process strategy How to win KERNEL airdrop rewards on Binance Full process strategy Apr 21, 2025 pm 01:03 PM

In the bustling world of cryptocurrencies, new opportunities always emerge. At present, KernelDAO (KERNEL) airdrop activity is attracting much attention and attracting the attention of many investors. So, what is the origin of this project? What benefits can BNB Holder get from it? Don't worry, the following will reveal it one by one for you.

Rexas Finance (RXS) can surpass Solana (Sol), Cardano (ADA), XRP and Dogecoin (Doge) in 2025 Rexas Finance (RXS) can surpass Solana (Sol), Cardano (ADA), XRP and Dogecoin (Doge) in 2025 Apr 21, 2025 pm 02:30 PM

In the volatile cryptocurrency market, investors are looking for alternatives that go beyond popular currencies. Although well-known cryptocurrencies such as Solana (SOL), Cardano (ADA), XRP and Dogecoin (DOGE) also face challenges such as market sentiment, regulatory uncertainty and scalability. However, a new emerging project, RexasFinance (RXS), is emerging. It does not rely on celebrity effects or hype, but focuses on combining real-world assets (RWA) with blockchain technology to provide investors with an innovative way to invest. This strategy makes it hoped to be one of the most successful projects of 2025. RexasFi

Galaxy Digital gets SEC approval for Nasdaq listing and reorganization Galaxy Digital gets SEC approval for Nasdaq listing and reorganization Apr 21, 2025 pm 02:45 PM

Galaxy Digital Holdings has been approved by the U.S. Securities and Exchange Commission (SEC) to officially launch the restructuring plan! Galaxy Digital has been approved by the SEC, and its Nasdaq listing and corporate structure restructuring plan has officially entered the next stage. The news was announced on Monday. The SEC has approved the registration statement for Galaxy Digital. The move is a key step in the company's plan to move its corporate structure from the Cayman Islands to Delaware, and at the same time, it will set up a new parent company, NewPubCo. "We are excited that the registration statement will take effect, which marks an important milestone in the development of Galaxy Digital and will continue to follow," said the CEO of Galaxy Digital.

See all articles