这是我用来计划CRON作业的代码。
add_filter( 'cron_schedules', 'isa_add_every_ten_seconds' );
function isa_add_every_ten_seconds( $schedules ) {
$schedules['every_ten_seconds'] = array(
'interval' => 10,
'display' => __( 'Every 10 seconds', 'sometext' )
);
return $schedules;
}
// Schedule an action if it's not already scheduled
if ( ! wp_next_scheduled( 'isa_add_every_ten_seconds' ) ) {
wp_schedule_event( time(), 'every_ten_seconds', 'isa_add_every_ten_seconds' );
}
// Hook into that action that'll fire every three minutes
add_action( 'isa_add_every_ten_seconds', 'every_ten_seconds_function_func' );
function every_ten_seconds_function_func() {
update_page();
}
我已经在本地服务器和真实服务器中进行了检查。不用找了。代码有什么问题?