Wordpress中的cron工作 [英] cron job in wordpress
本文介绍了Wordpress中的cron工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用默认功能在wordpress中运行cron作业。我想设置每15天运行一次的时间。
I want to run a cron job in wordpress using the default function. I want set the time to run every 15 days. How can I set the the for this?
function prefix_deactivation()
{
wp_clear_scheduled_hook('prefix_hourly_event_hook');
}
register_deactivation_hook(__FILE__, 'prefix_deactivation');
function prefix_activation()
{
wp_schedule_event(time(), 'everyminute', 'prefix_hourly_event_hook');
}
register_activation_hook(__FILE__, 'prefix_activation');
/* On activation, set a time, frequency and name of an action hook to be scheduled. */
function prefix_do_this_hourly()
{
// do something every hour
cronjob_options();
}
function cronjob_options()
{
/* your job */
}
add_action('prefix_hourly_event_hook', 'prefix_do_this_hourly');
推荐答案
<?php
add_filter( 'cron_schedules', 'cron_add_day' );
function cron_add_day( $schedules ) {
$schedules = array(
'day' => array( 'interval' => 86400*1,
'display' => __( 'Every Day' )
),
);
return $schedules;
}
?>
这篇关于Wordpress中的cron工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文