Skip to content

Instantly share code, notes, and snippets.

@chikaibeneme
Last active February 22, 2025 04:07
Show Gist options
  • Select an option

  • Save chikaibeneme/15ab5393efa06721fe3d7175d47c29be to your computer and use it in GitHub Desktop.

Select an option

Save chikaibeneme/15ab5393efa06721fe3d7175d47c29be to your computer and use it in GitHub Desktop.
publish all events
function forcefully_publish_all_events() {
global $wpdb;
// Get all event IDs directly from the database
$event_ids = $wpdb->get_col("
SELECT ID
FROM {$wpdb->posts}
WHERE post_type = 'tribe_events'
AND post_status NOT IN ('publish')
");
if (!empty($event_ids)) {
foreach ($event_ids as $event_id) {
// Update the post status to publish
wp_update_post([
'ID' => $event_id,
'post_status' => 'publish',
]);
}
echo count($event_ids) . " events have been forcefully published.";
} else {
echo "No unpublished events found.";
}
}
// Hook this function to an admin action or trigger it manually
add_action('admin_init', 'forcefully_publish_all_events');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment