How to resolve scheduled posts that say "Missed Schedule"

All we need is an easy explanation of the problem, so here it is.

My future posts are getting “missed”. They are not getting published on the time they should, and it says “Missed Schedule”.

I read somewhere that it could be a server issue, so how can I fix it?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Added the following to my theme’s functions.php:

define('WPMS_DELAY', 5);  // Run the below cron task every X minutes
define('WPMS_OPTION', 'wp_missed_schedule');

function wpms_replacements_deactivate() {
    delete_option(WPMS_OPTION);
}
register_deactivation_hook(__FILE__, 'wpms_replacements_deactivate');

// Run the following code on every request
function wpms_init() {
    remove_action('publish_future_post', 'check_and_publish_future_post');
    $last = get_option(WPMS_OPTION, false);

    // Exit here if less than WPMS_DELAY minutes has passed since we last ran
    if (($last !== false) && ($last > (time() - (WPMS_DELAY * 60))))
        return;

    // Find all posts whose scheduled time has passed and publish them
    update_option(WPMS_OPTION, time());
    global $wpdb;
    $scheduledIDs = $wpdb->get_col("
        SELECT `ID` FROM `{$wpdb->posts}`
        WHERE (
          ((`post_date` > 0) && (`post_date` <= CURRENT_TIMESTAMP()))
          OR ((`post_date_gmt` > 0) && (`post_date_gmt` <= UTC_TIMESTAMP()))
        )
        AND `post_status` = 'future'
        LIMIT 0, 10
    ");
    if (!count($scheduledIDs)) 
      return;
    foreach ($scheduledIDs as $scheduledID) {
        if (!$scheduledID) continue;
        wp_publish_post($scheduledID);
    }
}    
add_action('init', 'wpms_init', 0)

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply