我正在尝试在主题的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: ','','');
}
Run Code Online (Sandbox Code Playgroud)
小智 6
您可以访问http://www.example.com/wp-cron.php?doing_cron手动运行WordPress cron作业.在这里,您可以看到脚本创建的任何错误,在调试wp计划任务时非常有用.
| 归档时间: |
|
| 查看次数: |
4238 次 |
| 最近记录: |