How to Delete Old Events from WordPress Trash Automatically

Last Updated: December 2, 2024

How to Move old Events to Trash Automatically

EventON makes it easy to keep your website clean and organized by automatically moving outdated events to the trash. This feature ensures that events which have already ended do not clutter your site. To enable this option, simply follow these steps:

  1. Go to the EventON Settings: Navigate to EventON Settings > Advanced Settings.
  2. Enable the Option: Locate and enable the setting labeled “Auto move events to trash when the event date is past.”
  3. Save the Settings: After enabling the option, make sure to save your changes.

Once activated, EventON will automatically move events to the trash once their end date/time has passed.

How to Automatically Delete Trashed Event Posts

While the setting above will move past events to the trash, these trashed posts will still remain in your WordPress database. To fully delete them after they’ve been trashed, you can configure your WordPress site to automatically remove trashed posts after a set period. This will apply to all trashed posts on your site, not just events.

Here’s how you can set this up:

1. Edit the wp-config.php File

To enable automatic deletion of trashed posts, you’ll need to modify the wp-config.php file. This can be done through FTP, your cPanel file manager, or directly in your WordPress dashboard (if you have access to the file manager).

2. Add the Code

Once you’ve located the wp-config.php file, open it and add the following line towards the end of the file:

This code tells WordPress to automatically delete any posts in the trash after 7 days. You can customize this by changing the 7 to any number of days that works best for you. For example:

  • 0 will completely disable the trash feature and permanently delete posts immediately.
  • 30 will keep trashed posts for 30 days before they are permanently deleted.

3. Save the Changes

After adding the code, save the wp-config.php file. WordPress will now automatically delete posts that have been in the trash for the specified duration.

Summary

  • Step 1: Enable the auto-move feature in EventON Settings to trash past events.
  • Step 2: Add the EMPTY_TRASH_DAYS setting in your wp-config.php file to auto-delete trashed posts after a set number of days.

By configuring these two features, you can ensure that your WordPress site remains tidy, with outdated or unnecessary content being cleaned up automatically.

Did this article help you?

Ready to setup your calendar?