每x个小时的Wordpress cron时间表

时间:2014-12-08 04:48:56

标签: php wordpress cron

我有以下代码在每3小时执行cron作业以显示头部的时间。但是无法正常工作

register_activation_hook( __FILE__, 'wpce_prefix_activation' );
function wpce_prefix_activation() {
    wp_schedule_event( current_time ( 'timestamp' ), 10800, 'prefix_three_hourly_event_hook' );
}

add_action( 'prefix_three_hourly_event_hook', 'wpce_prefix_do_this_three_hourly' );
function wpce_prefix_do_this_three_hourly() {
    // do something every hour
    add_action('wp_head', 'add_link_in_head');

} // end function

function add_link_in_head(){
  echo time();

}//end of function

register_deactivation_hook( __FILE__, 'wpce_prefix_deactivation' );
function wpce_prefix_deactivation() {
    wp_clear_scheduled_hook( 'prefix_three_hourly_event_hook' );
}



    add_filter( 'cron_schedules', 'filter_cron_schedules' );
// add custom time to cron


 function filter_cron_schedules( $schedules ) {
        $schedules['fively'] = array(
            'interval' => 300,
            'display' => __('Once in Five minutes')
        ); 



$schedules['in_per_minute'] = array(
    'interval' => 60,
    'display' => __('In every minute')
);  

$schedules['in_per_ten_minute'] = array(
    'interval' => 600,
    'display' => __('Once in Ten minutes')
); 

$schedules['1_hours'] = array(
    'interval' => 3600,
    'display' => __('Hour')
);


$schedules['three_hourly'] = array(
    'interval' => 10800,
    'display' => __('Once in three hours')
);  
return $schedules;
}

我希望每3小时,5小时,6小时和7小时运行wordpress 中的cron作业。

如果有人能提供帮助,我会非常感激。 谢谢

0 个答案:

没有答案