我想用一个wp_schedule_event
function el_custom_cron_schedule( $schedules ) {
$schedules[\'el_every_5mn\'] = array(
\'interval\' => 5*60,
\'display\' => __( \'Every 5 minutes\' ),
);
return $schedules;
}
add_filter( \'cron_schedules\', \'el_custom_cron_schedule\' );
// Flush permalinks every 5mn
function el_flush_permalinks_activation() {
if ( !wp_next_scheduled( \'el_5mn_event\' ) ) {
wp_schedule_event(time(), \'el_every_5mn\', \'el_5mn_event\');
}
}
add_action(\'el_5mn_event\', \'el_flush_permalinks\');
add_action(\'wp\', \'el_flush_permalinks_activation\');
function el_flush_permalinks() {
flush_rewrite_rules(true);
}
因此,计划的任务可以工作,我通过发送电子邮件来测试它(
wp_mail
在函数中
el_flush_permalinks
)
问题是flush_rewrite_rules()
不是启动。我以为是hook wp
但不是。
谢谢你的帮助