# Upcoming Scheduled Tasks Widget

> Lists the next WP-Cron events and flags overdue ones, a quick way to spot a broken scheduler.

- Type: PHP
- Runs: Admin only
- Category: [Dashboard](https://wpide.com/library/category/dashboard/)
- Tags: dashboard, widget, cron
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/cron-events-dashboard-widget/

## Code

```php
add_action( 'wp_dashboard_setup', function () {
    if ( ! current_user_can( 'manage_options' ) ) {
        return;
    }

    wp_add_dashboard_widget( 'wpide_cron_events', 'Scheduled Tasks', function () {
        $crons = _get_cron_array();

        if ( empty( $crons ) ) {
            echo '<p>No scheduled tasks.</p>';
            return;
        }

        $now   = time();
        $shown = 0;

        echo '<table class="widefat striped"><tbody>';
        foreach ( $crons as $timestamp => $hooks ) {
            foreach ( $hooks as $hook => $events ) {
                foreach ( $events as $event ) {
                    if ( ++$shown > 12 ) {
                        break 3;
                    }
                    $late = $timestamp < $now - 10 * MINUTE_IN_SECONDS;
                    printf(
                        '<tr><td><code>%1$s</code><br><small>%2$s</small></td><td style="text-align:right;%3$s">%4$s</td></tr>',
                        esc_html( $hook ),
                        esc_html( ! empty( $event['schedule'] ) ? $event['schedule'] : 'once' ),
                        $late ? 'color:#d63638;font-weight:600' : '',
                        esc_html( ( $timestamp < $now ? 'overdue by ' : 'in ' ) . human_time_diff( $timestamp, $now ) )
                    );
                }
            }
        }
        echo '</tbody></table>';
    } );
} );
```

## Notes

Many overdue tasks usually mean WP-Cron is disabled or the site gets too little traffic.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Upcoming Scheduled Tasks Widget" 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/
