wp_schedule_event with dynamic names but same function

This is what the 4th parameter, $args is for. Use a single name for the event and pass the unique name as an argument. public function schedule($interval, $event): void { $args = array($event); if (! \wp_next_scheduled(‘my_scheduled_event’, $args)) { \wp_schedule_event(time(), $interval, ‘my_scheduled_event’, $args); } } Then you can have a single callback function that has access … Read more

HELP: Code To Check Status And Write Debug Entry

You can get the response code with wp_remote_retrieve_response_code() and log the response with error_log(). function my_better_uptime_heartbeat() { $worked = false; $response = wp_remote_get( ‘https://betteruptime.com/api/v1/heartbeat/<heartbeat_ID>’ ); if ( ! is_wp_error( $response ) ) { if ( 200 == wp_remote_retrieve_response_code( $response ) ) { // It worked, no need to log anything. $worked = true; } } … Read more

Change a Post’s Status based on the date from a custom field? (for Event posts)

There are several little issues with your code. This is what I use for the exact same thing though and it works: // expire events on date field. if (!wp_next_scheduled(‘expire_events’)){ wp_schedule_event(time(), ‘daily’, ‘expire_events’); // this can be hourly, twicedaily, or daily } add_action(‘expire_events’, ‘expire_events_function’); function expire_events_function() { $today = date(‘Ymd’); $args = array( ‘post_type’ => … Read more

Working function() doesn’t execute when triggered by WP CRON

Turns out that the issue within the code was neither the WP CRON nor was it the function that performs a WP_Query and SQL query of a custom DB table. As standalone functions, they both worked perfectly. The problem actually ended up being that I specified a timezone in the WP CRON using date_default_timezone_set( ‘America/Los_Angeles’ … Read more

WP CRON Fails At 13:00 Every Day

After further troubleshooting today, and with outstanding support from SiteGround, I have found the root cause. Turns out that every time termly_account_update wp-cron action ran (scheduled every 24 hours), it would crash the wp-cron processes, causing all other due now wp-cron actions to fail, including my my_heartbeat action. termly_account_update is a wp-cron job associated with … Read more