Cron

WP-Cron isn't a real cron job — it only runs when someone visits the site. This group covers the hooks that schedule, filter, and execute background tasks, and the gotchas that trip up anyone assuming it behaves like a system cron. 1 actions, 2 filters in this category.

cron_schedules

cron

Registers custom cron interval schedules

cron_schedules is the only way to add a custom recurring interval — WordPress ships with hourly, twicedaily, and daily only.

Signature

apply_filters( 'cron_schedules', array $schedules );

Example

add_filter( 'cron_schedules', function( $schedules ) {
    $schedules['every_fifteen_minutes'] = [
        'interval' => 15 * MINUTE_IN_SECONDS,
        'display'  => 'Every 15 Minutes',
    ];
    return $schedules;
} );

Common Use Cases

  • Add a custom recurring interval (e.g. every 15 minutes)
  • Register a weekly or non-standard interval
  • Match a plugin's own scheduled task frequency
  • Support finer-grained sync/polling than core's daily/hourly options
since 2.1.0wp-includes/cron.php

cron_request

cron

Filters the HTTP request WordPress uses to spawn WP-Cron

cron_request controls the loopback HTTP request WordPress fires to trigger wp-cron.php in the background — the standard hook for disabling that self-ping when cron is driven by a real system cron job instead.

Signature

apply_filters( 'cron_request', array $cron_request_array, string $doing_wp_cron );

Example

add_filter( 'cron_request', function( $request ) {
    error_log( 'Cron spawn request: ' . $request['url'] );
    return $request;
} );

Common Use Cases

  • Extend the timeout for slow-running cron jobs
  • Add authentication headers to the internal cron request
  • Log or monitor cron-spawn activity
  • Redirect the request when cron runs behind a load balancer or proxy
since 3.5.0wp-includes/cron.php

wp_scheduled_delete

cron

Fires daily via WP-Cron, right before old trashed posts are purged

wp_scheduled_delete runs once a day as a scheduled WP-Cron event, immediately before WordPress permanently deletes posts that have sat in Trash longer than EMPTY_TRASH_DAYS.

Signature

do_action( 'wp_scheduled_delete' );

Example

add_action( 'wp_scheduled_delete', function() {
    error_log( 'Trash cleanup cron run started.' );
} );

Common Use Cases

  • Piggyback custom database cleanup on the daily cron cycle
  • Log or monitor trash-purge activity
  • Audit how much content is being auto-deleted
  • Trigger a backup before old content is purged
since 2.9.0wp-includes/cron.php