WordPress CRON job working when reloading the page

WordPress Cron Jobs are not “real” Cronjobs, instead they relie on somebody visiting the site, then looking if it’s time to do scheduled jobs.

1.: Someone visits the website

2.: WordPress calls the file wp-cron.php

3.: wp-cron.php looks into the database if there are scheduled jobs that are due at this time.

4.: wp-cron.php does all of the scheduled jobs.

If you want to make sure that your cronjob is executed on time, you need to do some more steps:

1.: Schedule your cronjob. You did that already.

2.: disable the integrated WordPress-Cron. Edit your wp-config.php and insert define('DISABLE_WP_CRON', true); below the line define('DB_COLLATE','');

3.: Create a “real” cronjob on your server, set to run every so often (5 Minutes, 15 Minutes, 1 Minute, something like that). I don’t know if and how you can create a cronjob on your hosting, that’s something you got to ask your hosting company. Make the target of your cronjob yourdomain.com/wp-cron.php

4.: Success! Your cron should work now as intended!

Happy Coding!