How to optimize WordPress trash settings

Web Hosting in Pakistan

This article describes how to optimize the trash settings in WordPress.


ABOUT THE WORDPRESS TRASH FEATURE

The trash feature in WordPress allows you to recover posts, comments, pages, and attachments that have been deleted. By default, this recovery period is 30 days. After 30 days, WordPress permanently deletes items in the trash folder and they are gone forever.

Although the trash feature is convenient, items marked as trash take up space in the database. If your site receives heavy traffic or contains a lot of content, the amount of database space occupied by trash items could be significant, and potentially impact database performance.


OPTIMIZING TRASH SETTINGS

To reduce the amount of time that trash items are stored in the WordPress database, reduce the recovery period from 30 days to a shorter interval. To do this, follow these steps: 

  1. Log in to cPanel.
  2. In the Files section of the cPanel home screen, click File Manager.
  3. Navigate to the directory where WordPress is installed.


    Note: Typically, WordPress is installed in the public_html (document root) directory. However, if you installed WordPress in a subdirectory, navigate to that directory instead.



  4. Right-click the wp-config.php file, and then click Edit.
  5. Add the following line to the wp-config.php file. Replace X with the number of days you want WordPress to retain items marked as trash before it deletes them permanently:
    define( 'EMPTY_TRASH_DAYS', X );

    • Make sure the trash setting line above comes before the following line in the wp-config.php file, or else the setting has no effect:

      require_once(ABSPATH . 'wp-settings.php');

    • To disable the WordPress trash feature entirely, set X to 0 (zero).

  6. Click Save Changes.

Was this answer helpful?

 Print this Article

Also Read

How to Configure a Cron Job for WordPress

This article describes how to configure a cron job for WordPress. THE VIRTUAL WORDPRESS “CRON...

How to install and configure the UpdraftPlus plugin

This article describes how to install and configure the UpdraftPlus plugin to back up a WordPress...

How to install and configure the 2Checkout plugin for WordPress

This article describes how to install the 2Checkout plugin for WordPress. The 2Checkout plugin is...

How to disable plugins in WordPress

WordPress has a huge number of plugins available for adding features and extending functionality....

How to Optimize WordPress using W3 Total Cache and GTmetrix

As your site gains traffic and users, and as you add additional content, your site may begin to...

Web Hosting in Pakistan

Powered by WHMCompleteSolution