Skip to content

Instantly share code, notes, and snippets.

@talentedaamer
Last active July 31, 2018 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talentedaamer/dde325c69f836aef4d6be17612927fbc to your computer and use it in GitHub Desktop.
Save talentedaamer/dde325c69f836aef4d6be17612927fbc to your computer and use it in GitHub Desktop.
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