Using our settings for Event Maintenance can be really useful for keeping your site performance in good order, but sometimes you might want to keep Event Drafts from being deleted with this setting. Here is a snippet that will exclude drafts from that setting:
add_filter( 'tribe_events_delete_old_events_sql', function( $sql ) {
// Change the condition to exclude draft posts from cleanup.
$sql = str_replace(
"post_status NOT IN ( 'trash', 'tribe-ignored' )",
"post_status NOT IN ( 'trash', 'tribe-ignored', 'draft' )",
$sql
);
return $sql;
}, 10, 1 );
Add the code snippet to the functions.php of your theme, or use your preferred method for integrating snippets into your WordPress site, such as the free Code Snippets Plugin. You can also take a look at our page on the best practices for adding code snippets to your site, here.