Add schedule event OR Cron event with wp_schedule_event(). See https://maheshwaghmare.com/doc/wordpress-cron/
<?php | |
/** | |
* Add schedule event or Cron event with wp_schedule_event() | |
* | |
* @todo Change the `prefix_` and with your own unique prefix. | |
* | |
* @since 1.0.0 | |
* | |
* @return void | |
*/ | |
if( ! function_exists( 'prefix_add_scheduled_event' ) ) : | |
function prefix_add_scheduled_event() { | |
// Schedule the event if it is not scheduled. | |
if ( ! wp_next_scheduled( 'prefix_cron_hook' ) ) { | |
wp_schedule_event( time(), 'every_ten_minutes', 'prefix_cron_hook' ); | |
} | |
} | |
add_action( 'admin_init', 'prefix_add_scheduled_event' ); | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment