I just spent way too much time trying to troubleshoot why my wp-cron job wasn't running. It seems, under 4.9.8, the only way to run cron is by calling the wp-cron.php file as a URL.

The docs say though, that it should run on page loads, though I can't locate where. Any help, please?

  • 1
    Do you have DISABLE_WP_CRON defined in wp-config? – Krzysiek Dróżdż Dec 7 at 9:02
  • I do not, at least not in any way I can locate. – Drazisil Dec 7 at 12:44
up vote 1 down vote accepted

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.

  • I'm using the official Wordpress Docker container, do you have any details on the possible server configurations that would break this? – Drazisil Dec 7 at 13:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.