Many times I have code and I want to make sure it only runs in a cron context, or it never runs in a cron context.
Is there an is_cron_running
style function?
Many times I have code and I want to make sure it only runs in a cron context, or it never runs in a cron context.
Is there an is_cron_running
style function?
- 1 I'm a bit fed up of constantly googling for the answer to this then forgetting it, and the SEO on stack exchange is pretty good – Tom J Nowell ♦ Commented Dec 1, 2018 at 20:10
1 Answer
Reset to default 2Yes, wp_doing_cron
will return true if the current request is a WP Cron request, or if it's triggered from WP CLI
https://developer.wordpress/reference/functions/wp_doing_cron/