Where in the page load code is wp-cron triggered?

The WordPress cron is run by the wp_cron() function, which is hooked to run on the init hook, which runs on every page load.

wp_cron() is defined in wp-includes/cron.php and hooked in wp-includes/default-filters.php.

The wp_cron() function kicks off a wp_remote_post() request to /wp-cron.php. Some server configurations prevent scripts sending a request to the same domain like this however, so as an alternative you can set the ALTERNATE_WP_CRON constant to true. When enabled this redirects the user to the current URL but with ?doing_wp_cron= added to the URL, instead of the post request.

Leave a Comment