WordPress Post Missed Schedule

I’ve got a lot of blogs – many that I don’t check for errors as often as I should. Some days, I’ll set aside a few hours and past in some posts that I’ll schedule to publish throughout the week so I can set and forget.

I found an error in two of the them today that caused the bologs to fail to publish certain posts as scheduled. Instead, in the WP control panel, I was met with a message that said “Missed Schedule“. Since the error wasn’t caused by an upgrade or modification, and given that it’s happening with regularity, it suggests a modification or error server-side, but I can’t be sure. It seems to be more commonly associated with version 2.9 (with a supposed ‘fix’ in 2.9.1), but I’m still getting it in version 3.0.

Missed Schedule

 After a little investigation, it turns out that future posts are assigned a cronjob [ wp_schedule_single_event($unix_time_stamp, 'publish_future_post', array($post_ID)) ] – a somewhat unusual means of accomplishing the task. Far be it from me to question the excellent gurus at WordPress – I’m sure they have their reasons, but one would think a more effective means would be to simply check the database for scheduled posts… and then publish them.

Rather than try and build my own workaround, I found this excellent little plugin at WordPress.org. As per the author’s description, it will “Schedule a hook which will be executed once by the WordPress actions core at a time which you specify. The action will fire off when someone visits your WP blog if the schedule time has passed.”

The hook will disable native cron function and replace it with its own. You can disable the particular line from within the code if it conflicts with other plugins. I’ve tested it successfully with WordPress versions up until 3.0.

If you’re somebody that prefers to modify code, you can alter the cron.php file in the includes directory with the following. It may fix the error if it’s caused by a timeout.

Replace this:

$cron_url = get_option( 'siteurl' ) . '/wp-cron.php?doing_wp_cron';
wp_remote_post( $cron_url, array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true)) );
}

With this. We’ve changed 0.1 to ’20′.

$cron_url = get_option( 'siteurl' ) . '/wp-cron.php?doing_wp_cron';
wp_remote_post( $cron_url, array('timeout' => 20, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true)) );
}

This isn’t recommended because it means that you’ll have to modify the code every time there’s a new WP release.

First Name:
Your Email Address:
 


If you liked this article, you may also like:

  1. Add WordPress tags within your post
  2. Convert Currency on your Website or in a WordPress Post (with Shortcode)
  3. Generate QR Codes on Your Website or WordPress Post with Google Chart Tools
  4. Find and Replace Words in a WordPress Post
  5. Post a Form with CURL (and How Spammers Automate Spam Comments to WordPress)
About Marty

is a passionate web developer from Sydney, Australia. He owns about 600 websites and makes a healthy living from working the web. As a day job, he works as a pilot for an international airline. Follow Marty on Twitter or Google+.

Please leave a comment or question!

*