REST API & Developer PHP Intermediate

List Scheduled Cron Events Under Tools

Add a read-only Tools > Cron Events page that lists every scheduled WP-Cron task, when it runs next and how often.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 34 lines
add_action( 'admin_menu', function (): void {
	add_management_page( 'Cron Events', 'Cron Events', 'manage_options', 'nahnu-cron-events', 'nahnu_render_cron_events' );
} );

function nahnu_render_cron_events(): void {
	$crons     = _get_cron_array() ?: [];
	$schedules = wp_get_schedules();
	?>
	<div class="wrap">
		<h1>Cron Events</h1>
		<p>Current time: <?php echo esc_html( wp_date( 'Y-m-d H:i:s' ) ); ?>. WP-Cron runs on page visits, so tasks may run a little late.</p>
		<table class="widefat striped">
			<thead><tr><th>Hook</th><th>Next run</th><th>Schedule</th><th>Arguments</th></tr></thead>
			<tbody>
			<?php foreach ( $crons as $timestamp => $hooks ) : ?>
				<?php foreach ( $hooks as $hook => $events ) : ?>
					<?php foreach ( $events as $event ) : ?>
						<tr>
							<td><code><?php echo esc_html( $hook ); ?></code></td>
							<td>
								<?php echo esc_html( wp_date( 'Y-m-d H:i:s', $timestamp ) ); ?>
								<?php if ( $timestamp < time() ) : ?><strong>(overdue)</strong><?php endif; ?>
							</td>
							<td><?php echo esc_html( $event['schedule'] ? ( $schedules[ $event['schedule'] ]['display'] ?? $event['schedule'] ) : 'Once' ); ?></td>
							<td><code><?php echo esc_html( $event['args'] ? wp_json_encode( $event['args'] ) : '' ); ?></code></td>
						</tr>
					<?php endforeach; ?>
				<?php endforeach; ?>
			<?php endforeach; ?>
			</tbody>
		</table>
	</div>
	<?php
}

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

When a scheduled email doesn’t send or a backup doesn’t run, the first question is whether the task is even scheduled. This snippet adds a simple page that answers it, without installing a plugin.

How it works

_get_cron_array() returns every scheduled event, grouped by run time and hook name. The page lists each one with its next run time in your site’s time zone, its schedule name from wp_get_schedules() and any arguments.

Events whose time has passed are marked overdue, which usually means WP-Cron isn’t running properly.

Things to watch

  • The page is read-only. To run or delete events, use WP Crontrol or WP-CLI.
  • Only administrators can see it.
  • Many overdue events usually mean DISABLE_WP_CRON is on without a real server cron, or the site gets very little traffic.

How to test it

Go to Tools → Cron Events. You should see core tasks like wp_version_check and wp_scheduled_delete.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only