I have a WordPress function that I want to run once daily at a specific time. How should I go about doing this, since WP cron cannot be set to a particular time?
3 comments
Comments are closed.
I have a WordPress function that I want to run once daily at a specific time. How should I go about doing this, since WP cron cannot be set to a particular time?
Comments are closed.
you can absolutely use wp_cron to specify a time:
This is an over simplified example. Some type of checking needs to be done so that you don’t end up with a boatload of hooks scheduled, but it should give you an idea of how to set it up for a particular time. Further, it needs to be understood that wp_cron is triggered by page loads so if your site hasn’t got huge amounts of traffic, then the function won’t fire precisely at the time defined. There are workarounds for this though.
You can go through this link.
http://codex.wordpress.org/Function_Reference/wp_schedule_event
Just to add to @Will the Web Mechanic’s answer.
I needed to use
default_timezone_set didn’t work for me