# Publish Posts That Missed Their Schedule

> Checks every few minutes for scheduled posts stuck with a "Missed schedule" label and publishes them, a common problem on low-traffic sites.

- Type: PHP
- Runs: Run everywhere
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: admin, scheduling, cron
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/publish-missed-schedule-posts/

## Code

```php
// How often to check, in seconds.
$wpide_missed_check_every = 5 * MINUTE_IN_SECONDS;

add_action( 'init', function () use ( $wpide_missed_check_every ) {
    if ( get_transient( 'wpide_missed_schedule_lock' ) ) {
        return;
    }

    set_transient( 'wpide_missed_schedule_lock', 1, $wpide_missed_check_every );

    $missed = get_posts( array(
        'post_type'        => 'any',
        'post_status'      => 'future',
        'date_query'       => array( array( 'column' => 'post_date_gmt', 'before' => gmdate( 'Y-m-d H:i:s' ) ) ),
        'numberposts'      => 10,
        'fields'           => 'ids',
        'suppress_filters' => true,
    ) );

    foreach ( $missed as $post_id ) {
        wp_publish_post( $post_id );
    }
}, 30 );
```

## Notes

A real server cron hitting wp-cron.php is the long-term fix; this is a safety net.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Publish Posts That Missed Their Schedule" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
