WP-Cron custom intervals are being ignored.
-
I’m currently working on a site that needs a custom 10 minute interval for WP-Cron. As shown below, I have setup the code for this interval, but every time, the next due date for the WP-Cron job is set for the present moment and not 10 minutes in the future.
Here is the code that I am using to create the custom interval:
function cronAddTen($schedules) { $schedules['ten'] = array( 'interval' => 600, 'display' => __('Every Ten Minutes') ); return $schedules; }
I am calling this function via the required filter:
add_filter('cron_schedules', 'cronAddTen');
Finally, here is the code to setup the WP-Cron:
if (!wp_next_scheduled('clear_old_posts')) { wp_schedule_event( time(), 'ten', 'clear_old_posts'); }
The above code for setting the interval is in a function which has been attached to the wp action. Also, for test purposes, my code is currently clearing the scheduled event just prior to the code for the event setup.
Using the Core Control plugin, I can see the WP-Cron Job and the Name of the Interval is displayed correctly as Every Ten Minutes, but the due date for job is always the present time and not 10 minutes in the future.
One question I have is where exactly does the add_filter line for defining the custom interval have to go and where can it not be? I have tried placing it in:
1) My Themes functions.php file
2) An active plugin file
3) Inside the constructor of a active plugin class
but all the placements have yielded the same present due date issue.As a note, the built in intervals for WP-Cron work as expected and I have tried this code on two different servers with the same result. I cannot post a link to this site because one, this issue is on the admin side and because this is a client’s site.
- The topic ‘WP-Cron custom intervals are being ignored.’ is closed to new replies.