admin管理员组文章数量:1130349
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?
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?
Share Improve this question asked Dec 7, 2018 at 8:56 DrazisilDrazisil 1034 bronze badges 2 |1 Answer
Reset to default 2The 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 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?
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?
Share Improve this question asked Dec 7, 2018 at 8:56 DrazisilDrazisil 1034 bronze badges 2-
1
Do you have
DISABLE_WP_CRONdefined in wp-config? – Krzysiek Dróżdż Commented Dec 7, 2018 at 9:02 - I do not, at least not in any way I can locate. – Drazisil Commented Dec 7, 2018 at 12:44
1 Answer
Reset to default 2The 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.
本文标签: Where in the page load code is wpcron triggered
版权声明:本文标题:Where in the page load code is wp-cron triggered? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749120674a2318952.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


DISABLE_WP_CRONdefined in wp-config? – Krzysiek Dróżdż Commented Dec 7, 2018 at 9:02