您可以使用以下步骤使其工作:`1. Setup an schedule
function my_schedule( $schedules ) {
$schedules[\'hourly\'] = array(
\'interval\' => 60 * 60,
\'display\' => __( \'One houre\' )
);
return $schedules;
}
add_filter( \'cron_schedules\', \'my_schedule\' );
2. Register the activation hook
register_activation_hook( __FILE__, \'my_activation\' );
function my_activation() {
$timestamp = wp_next_scheduled( \'my_hourly_event\' );
if( false == $timestamp ){
wp_schedule_event( time(), \'hourly\', \'my_hourly_event\' );
}
}
3. Add action on the event
function do_this_hourly() {
// The cron functionality and rest of your code here
}
add_action( \'my_hourly_event\', \'do_this_hourly\' );