8

我正在尝试在主题中安排一个事件,functions.php但我无法让它“触发”。我正在使用 Cron View 插件,它显示了正确安排的事件,但什么时候执行都没有发生。

这是我的代码

if ( ! wp_next_scheduled( 'prefix_hourly_event' ) ) {
    wp_schedule_event( time(), 'hourly', 'prefixhourlyevent');       
}
add_action( 'prefixhourlyevent', 'prefix_do_this_hourly' );

function prefix_do_this_hourly() {                
    wp_mail('myemail@gmail.com','Cron is working', 'Cron is working: ','','');
}
4

1 回答 1

7

您可以通过访问 http://www.example.com/wp-cron.php?doing_cron手动运行 WordPress cron 作业。在这里您将能够看到脚本创建的任何错误,这在调试 wp 计划任务时非常有用。

于 2014-02-11T06:45:09.347 回答