See the following thread on how to select events in the past: https://ww.wp.xz.cn/support/topic/past-events-not-in-panel/
Thank you for your reply.
I need to keep those of the past year, and delete those form the years before that.
The way I understand it, the “past event” filter gives all of the events from the past, not just those older than 1 year.
You can sort it by date by clicking on the “Date and Time” heading. Then just select the ones you want to delete.
Indeed, I’m aware of this feature as well. But it would take very, very long to sort though 5000 events like this.
Is there a way to use a different filter?
Thank you
Make a backup of your database first!
The following should move events older than 1 year into the Trash (I tried it out and it worked fine on my site).
$latest = date('Y-m-d', strtotime('-1 year', strtotime('now')));
$earliest = date('Y-m-d', strtotime('-30 year', strtotime('now')));
$events = EM_Events::get(['scope' => "$earliest,$latest", 'order' => 'DESC']);
foreach ( $events as $event ) {
$event->delete();
}
You can use the Code Snippets plugin to run this code snippet (choose the “Only run once” option).