Home › Forums › Calendar Products › Events Calendar PRO › Bulk delete old events
- This topic has 6 replies, 4 voices, and was last updated 9 years, 3 months ago by
Dean Spencer.
-
AuthorPosts
-
December 12, 2016 at 11:28 am #1204833
Dean Spencer
ParticipantHi we have been using the Events Calendar Pro for about 3 years, and have thousands of events on our website from 2013, 2014 and 2015.
I am familiar with phpMyAdmin but am not good with code, joins or syntax.
We have tried deleting events individually, but the website is crawling and continually crashes. We have also tried the Event Cleanup Plugin but that isn’t visible in Admin and Available Tools when we activate it?
Can you please tell me the code / syntax to delete all events 4 months old, or older?
Thank you,
Dean
December 12, 2016 at 6:31 pm #1205016Nico
MemberHi there Dean,
Thanks for getting in touch with us! Glad to help a long time customer 🙂
Have you tried using Bulk Delete Plugin? It worked pretty well for me in the past. If this doesn’t help I can give the SQL query a try. In any case be sure to back up the database before the cleanup!
Cheers,
NicoDecember 13, 2016 at 9:52 am #1205416Dean Spencer
ParticipantHi I have tried the Bulk Delete tool which does work, but it only deletes about 20 or 30 events at a time before crashing the server. I then need to restart the server before I can get back into wp-admin.
I have backed up the database using phpMyAdmin so am able to restore.
If you could provide an SQL query that would be fantastic. We would like to delete ALL old events, keeping today and future events.
Thank you!
December 13, 2016 at 1:51 pm #1205528Nico
MemberSure Dean,
I’ve already escalated your request to a developer who will be able to provide the necessary SQL query for the clean up! Will share it with you when ready 🙂
Best,
NicoDecember 14, 2016 at 10:19 am #1206025Nico
MemberHey Dean,
I have some news on this! Brook from the support team, commented that deleting the events via MySQL as opposed to using WordPress wp_delete_post function might not be the best. He suggest you run ‘tribe_get_events()’ request, iterate through each id, and do a ‘wp_delete_post()’ on each. You could even wrap this up into a function and have it run on ‘wp_schedule_event()’. Or maybe put a limit on it of 50 events, and run it several times on page load.
If you decide the go the MySQL way here’s a base SQL query that only needs a ‘WHERE’ clause that searches the ‘postmeta’ table for events with an ‘_EventEndDate’ from four+ months ago:
https://gist.github.com/elimn/e5de5d2037678de0b926c307022571c5
Read the comments, it’s crafted to delete recurring events instances not single events, but the modifications should be simple enough. He also mentioned that deleting events this way might lead to orphan recurring child events. Are you just using single events in your site? How many events do you actually have in the site?
Please let me know if you are able to modify the query to make this work, or if you still need further help on this,
Best,
NicoJanuary 5, 2017 at 8:35 am #1213799Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Bulk delete old events’ is closed to new replies.
