x分毎にwp-cronを実行する方法

Pocket

add_filter( 'cron_schedules', 'cron_add_5min' );
function cron_add_5min( $schedules ) {
    $schedules['5min'] = array(
        'interval' => 5*60,
        'display' => __( 'Once every five minutes' )
    );
    return $schedules;
}
if ( ! wp_next_scheduled( 'my_task_hook' ) ) {
  wp_schedule_event( time(), '5min', 'my_task_hook' );
}
add_action( 'my_task_hook', 'do_stuff' );
function do_stuff(){
    // do stuff
}

 

Comments on this post

No comments.

Leave a Reply

Your email address will not be published. Required fields are marked *

Trackbacks and Pingbacks on this post

No trackbacks.

TrackBack URL