and like us on FB

This code was required some time back when one of our sites failed to publish as scheduled. Instead, in the WP control panel, I was met with a message that said “Missed Schedule“.

WordPress Post 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.

This error is quite old and it’s unlikely the error will continue to cause issues with your installation.

After a little investigation, it turns out that future posts are assigned a cronjob via the WP function wp_schedule_single_event – 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:

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

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

Shortt URL for this post: http://shor.tt/Dy4