Instantly share code, notes, and snippets.

Embed
What would you like to do?
add custom weekly, monthly and 30 minutes cron time schedules via cron_schedules filter hook
<?php
function wptc_add_intervals( $schedules ) {
// add a 'weekly' interval
if( ! isset( $schedules['weekly'] ) ) {
$schedules['weekly'] = array(
'interval' => 604800, // seconds in a week
'display' => __('Once Weekly')
);
}
// add a 'monthly' interval
if( ! isset( $schedules['monthly'] ) ) {
$schedules['monthly'] = array(
'interval' => 2635200, // seconds in a month
'display' => __('Once a month')
);
}
// add a '30min' interval
if( ! isset( $schedules['30min'] ) ) {
$schedules['30min'] = array(
'interval' => 1800, // seconds in 30 minutes or use 30*60
'display' => __('Once Every 30 minutes')
);
}
return $schedules;
}
add_filter( 'cron_schedules', 'wptc_add_intervals' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment