我已经尝试过这个解决方案,但没能奏效Run function at specific time
以下是我的示例:
//this is for testing purposes
function my_cron_schedules($schedules){
if(!isset($schedules["1min"])){
$schedules["1min"] = array(
\'interval\' => 60,
\'display\' => __(\'Once a minute\'));
}
return $schedules;
}
add_filter(\'cron_schedules\',\'my_cron_schedules\');
if ( ! wp_next_scheduled( \'my_scheduled_event\' ) ) { wp_schedule_event(
strtotime( \'2019-01-04 19:39:00\' ), \'1min\', \'my_scheduled_event\' ); }
add_action( \'my_scheduled_event\', \'update_ratings\' );
function update_ratings() {
//do some stuff
}