Last active
February 22, 2025 04:07
-
-
Save chikaibeneme/15ab5393efa06721fe3d7175d47c29be to your computer and use it in GitHub Desktop.
publish all events
This file contains hidden or 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
| 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