Skip to content

Instantly share code, notes, and snippets.

@maheshwaghmare
Created June 2, 2020 14:40
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 maheshwaghmare/268fda83d34896ef66766aee1e1acd66 to your computer and use it in GitHub Desktop.
Save maheshwaghmare/268fda83d34896ef66766aee1e1acd66 to your computer and use it in GitHub Desktop.
Add custom cron schedules with filter `cron_schedules`. See https://maheshwaghmare.com/doc/wordpress-cron/
<?php
/**
* Add Cron Schedules
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*
* @param array() $schedules Existing schedules.
* @return array
*/
if( ! function_exists( 'prefix_add_cron_schedules' ) ) :
function prefix_add_cron_schedules( $schedules = array() ) {
$schedules['every_ten_minutes'] = array(
'interval' => 600, // 600 seconds means 10 minutes.
'display' => __( 'Every 10 minutes', 'textdomain' ),
);
return $schedules;
}
add_filter( 'cron_schedules', 'prefix_add_cron_schedules' );
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment