Skip to content

Instantly share code, notes, and snippets.

@codescribblr
Created March 17, 2014 16:23
Show Gist options
  • Select an option

  • Save codescribblr/9602614 to your computer and use it in GitHub Desktop.

Select an option

Save codescribblr/9602614 to your computer and use it in GitHub Desktop.
Modifies cron schedule in Wordpress allowing you to add custom schedules. From http://wp.smashingmagazine.com/2013/10/16/schedule-events-using-wordpress-cron/
add_filter( 'cron_schedules', 'wi_add_weekly_schedule' );
function wi_add_weekly_schedule( $schedules ) {
$schedules['weekly'] = array(
'interval' => 7 * 24 * 60 * 60, //7 days * 24 hours * 60 minutes * 60 seconds
'display' => __( 'Once Weekly', 'my-plugin-domain' )
);
/*
You could add another schedule by creating an additional array element
$schedules['biweekly'] = array(
'interval' => 7 * 24 * 60 * 60 * 2
'display' => __( 'Every Other Week', 'my-plugin-domain' )
);
*/
return $schedules;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment