How to Set the Trash Retention Period in WordPress

When creating an article or page, you might decide to discard or discontinue some of them, and those items will end up in the trash category.

If you want to save hosting disk space, you can automatically set how long trash items are kept in WordPress for you.

The method for setting the trash retention period in WordPress that we will discuss here does not use any additional plugins, so you do not need to add a plugin specifically for automatic trash cleanup.

Prerequisites for Setting the Trash Retention Period in WordPress

  • Basic WordPress file editing
  • Ability to edit thewp-config.php file, whether through hosting, VPS, console, or file explorer on localhost.

How to Set the Trash Retention Period in WordPress

Before we go further, I will add the code via cPanel here. If you are not using cPanel, you can adjust this using the file manager on the panel you are using. Additionally, by default, trash files are automatically deleted from the website in 30 days, so if you want to keep trash files for 30 days, you do not need to make any changes.

  1. First, log in to your cPanel. cPanel login details are usually sent to your registered email after the service is active.
    Cara Menentukan Lama Artikel Sampah Tersimpan di WordPress
  2. Find and open theFile Manager
    Cara Menentukan Lama Artikel Sampah Tersimpan di WordPress
  3. page. Open your WordPress installation folder. Usually, if WordPress is installed on the main domain on your hosting, the installation folder is in thepublic_html
    Cara Menentukan Lama Artikel Sampah Tersimpan di WordPress
  4. folder. Find and edit thewp-config.php
    Cara Menentukan Lama Artikel Sampah Tersimpan di WordPress
  5. file. Add the following line above the line /* That’s all, stop editing! Happy publishing. */
//Auto delete trash itemdefine('EMPTY_TRASH_DAYS', 1 ); //Ubah integer (1) menjadi jumlah hari berkas sampah disimpan
  1. Save the changes, and you have successfully set how long trash items will be kept on your website.
    Cara Menentukan Lama Artikel Sampah Tersimpan di WordPress

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...