-
-
Save codingmusician/c33994c8d2c1a69aa94cc73d52d37ff2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Description: Trash expired events automatically | |
* | |
* Usage: copy the snippet in your active (child) theme's functions.php file | |
* | |
* Plugins: The Events Calendar | |
* Author: Modern Tribe | |
* Last updated: February 19, 2019 | |
*/ | |
function tribe_trash_event_after_expiration(){ | |
if(is_admin()){ | |
return; | |
} | |
$args = ["end_date" => date("Y-m-d 23:59:59", strtotime("yesterday", current_time("timestamp"))), "posts_per_page" => 50]; | |
$events = tribe_get_events($args); | |
foreach($events as $e){ | |
wp_trash_post($e->ID); | |
} | |
} | |
add_action("init", "tribe_trash_event_after_expiration"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment