2017-05-19 29 views
0

私はwpで新しく、wp_schedule_eventを使用する必要があります。 私はまた、カスタムを作成するには、このコードワードプレスでスケジュールされたイベントは一度だけ実行されます

add_action('my_func', 'my_func'); 
function myFunction() { 
    error_log("asd"); 
} 

function activateSchedule($recurrence) { 
    if(!wp_next_scheduled('my_func')) { 
    // Schedule the event 
    wp_schedule_event(current_time('timestamp'), $recurrence, 'my_func'); 
    } 
} 

にしようとしているが、このよう

function isa_add_cron_recurrence_interval($schedules) { 

    $schedules['5sec'] = array(
     'interval' => 5, 
     'display' => __('Every 5 seconds', 'textdomain') 
); 
} 

add_filter('cron_schedules', 'isa_add_cron_recurrence_interval'); 

を再発しかし、スケジュール機能は一度だけ実行されます。 私は行方不明ですか?

答えて

0

これは、古い質問かもしれませんが、私は同様の問題を持っていた:あなたの関数は、return文が欠落しています。

function isa_add_cron_recurrence_interval($schedules) { 

    $schedules['5sec'] = array(
     'interval' => 5, 
     'display' => __('Every 5 seconds', 'textdomain') 
); 
    return $schedules; 
} 
関連する問題