Cron Job 没有出现在 WP-Control 插件的 cron 列表中

Cron Job not appearing in the cron list of WP-Control plugin

我正在尝试为所有客户设置一个 cron 作业来更新他们的库存。我调查了 Cron job in WordPress not working and cron job in wordpress 但无法让它出现在 cron 列表中(WP-Control)。

我正在使用这个:

add_action('plugins_loaded', 'cron_add_everyday');
add_filter( 'cron_schedules', 'cron_add_everyday' );

function cron_add_everyday( $schedules ) {

   $schedules = array('everyday' => array( 'interval' => 86400*1,
                                           'display' => __( 'Every Day')),);
   return $schedules;
}

我用这个只是为了测试我是否可以让它出现在列表中。我错过了什么吗?谢谢

好的,我明白了。完整代码:

//CUSTOM TIMER 15 minuts, you can change for your won
function myprefix_custom_cron_schedule( $schedules ) {
   $schedules['15Minuts'] = array(
                                  'interval' => 900, // 15 minuts in secounds
                                  'display'  => __( '15 minuts' ),
                                   );
   return $schedules;
}
//ADD it
add_filter( 'cron_schedules', 'myprefix_custom_cron_schedule' );

//Schedule an action if it's not already scheduled
  if ( ! wp_next_scheduled( 'Your_Function_Hook' ) ) {
       wp_schedule_event( time(), '15Minuts', 'Your_Function_Hook' );
  }

///Hook into that action that'll fire every 15 minuts
add_action( 'Your_Function_Hook', 'Your_Function' );

//create your function, that runs on the cron you just made
function Your_Function() {
  echo 'Hi its 15 minuts';
}

这不是我做的,功劳归https://wordpress.stackexchange.com/questions/179694/wp-schedule-event-every-day-at-specific-time。希望它能帮助一些人!

编辑:如果你安装了一个插件,你可以用一个图形用户界面看到你的cron作业,我有wp-control。可以在 yourdomain/wp-admin/tools.php?page=crontrol_admin_manage_page

检查 crons