𝗪𝗼𝗿𝗱𝗣𝗿𝗲𝘀𝘀 𝗖𝗿𝗼𝗻 𝗘𝘅𝗽𝗹𝗮𝗶𝗻𝗲𝗱
Emails do not send. Cleanup skips. Reminders never fire. Your code looks fine. It works locally. It fails on production.
Most cron issues are not syntax errors. You misunderstand how WordPress scheduling works.
WP Cron is a system for automatic jobs.
- Send reminder emails.
- Clean old logs.
- Sync data.
Server cron runs at an exact time. WP Cron runs based on traffic.
High traffic is reliable. Low traffic is delayed. Staging is unpredictable.
Follow this workflow:
- Check if the job exists.
- Schedule the event.
- Connect the function.
Use these tools:
- wp_schedule_event for repeating tasks.
- wp_schedule_single_event for one-time tasks.
- wp_next_scheduled to check for existing jobs.
- wp_unschedule_event to stop tasks.
Avoid these mistakes:
- Skipping the check creates duplicates.
- Forgetting to unschedule creates ghost jobs.
- Relying on low traffic leads to delays.
- Missing the action hook stops the function.
Production tip: Disable WP Cron in your config file. Set up a real server cron instead.
Source: https://dev.to/mdhemalakhand1999/wordpress-cron-explained-real-world-guide-after-6-years-36m2