admin管理员组文章数量:1130349
I have tried this solution but I can't get it to work Run function at specific time
Here is my example:
//this is for testing purposes
function my_cron_schedules($schedules){
if(!isset($schedules["1min"])){
$schedules["1min"] = array(
'interval' => 60,
'display' => __('Once a minute'));
}
return $schedules;
}
add_filter('cron_schedules','my_cron_schedules');
if ( ! wp_next_scheduled( 'my_scheduled_event' ) ) { wp_schedule_event(
strtotime( '2019-01-04 19:39:00' ), '1min', 'my_scheduled_event' ); }
add_action( 'my_scheduled_event', 'update_ratings' );
function update_ratings() {
//do some stuff
}
I have tried this solution but I can't get it to work Run function at specific time
Here is my example:
//this is for testing purposes
function my_cron_schedules($schedules){
if(!isset($schedules["1min"])){
$schedules["1min"] = array(
'interval' => 60,
'display' => __('Once a minute'));
}
return $schedules;
}
add_filter('cron_schedules','my_cron_schedules');
if ( ! wp_next_scheduled( 'my_scheduled_event' ) ) { wp_schedule_event(
strtotime( '2019-01-04 19:39:00' ), '1min', 'my_scheduled_event' ); }
add_action( 'my_scheduled_event', 'update_ratings' );
function update_ratings() {
//do some stuff
}
Share
Improve this question
asked Jan 4, 2019 at 19:55
Ante MedicAnte Medic
694 silver badges12 bronze badges
2
- Did you initiate a request to trigger the event? WordPress cron isn't true cron- it will only run when someone loads a page on your site. – Milo Commented Jan 5, 2019 at 3:57
- The problem was in scheduled cron jobs. While testing I had previously set cron job for the same hook. After inspecting cron jobs I managed to delete that test schedule and now it is working. – Ante Medic Commented Jan 5, 2019 at 9:25
1 Answer
Reset to default 0The problem was in scheduled cron jobs. While testing I had previously set cron job for the same hook. After inspecting cron jobs I managed to delete that test schedule and now it is working.
I have tried this solution but I can't get it to work Run function at specific time
Here is my example:
//this is for testing purposes
function my_cron_schedules($schedules){
if(!isset($schedules["1min"])){
$schedules["1min"] = array(
'interval' => 60,
'display' => __('Once a minute'));
}
return $schedules;
}
add_filter('cron_schedules','my_cron_schedules');
if ( ! wp_next_scheduled( 'my_scheduled_event' ) ) { wp_schedule_event(
strtotime( '2019-01-04 19:39:00' ), '1min', 'my_scheduled_event' ); }
add_action( 'my_scheduled_event', 'update_ratings' );
function update_ratings() {
//do some stuff
}
I have tried this solution but I can't get it to work Run function at specific time
Here is my example:
//this is for testing purposes
function my_cron_schedules($schedules){
if(!isset($schedules["1min"])){
$schedules["1min"] = array(
'interval' => 60,
'display' => __('Once a minute'));
}
return $schedules;
}
add_filter('cron_schedules','my_cron_schedules');
if ( ! wp_next_scheduled( 'my_scheduled_event' ) ) { wp_schedule_event(
strtotime( '2019-01-04 19:39:00' ), '1min', 'my_scheduled_event' ); }
add_action( 'my_scheduled_event', 'update_ratings' );
function update_ratings() {
//do some stuff
}
Share
Improve this question
asked Jan 4, 2019 at 19:55
Ante MedicAnte Medic
694 silver badges12 bronze badges
2
- Did you initiate a request to trigger the event? WordPress cron isn't true cron- it will only run when someone loads a page on your site. – Milo Commented Jan 5, 2019 at 3:57
- The problem was in scheduled cron jobs. While testing I had previously set cron job for the same hook. After inspecting cron jobs I managed to delete that test schedule and now it is working. – Ante Medic Commented Jan 5, 2019 at 9:25
1 Answer
Reset to default 0The problem was in scheduled cron jobs. While testing I had previously set cron job for the same hook. After inspecting cron jobs I managed to delete that test schedule and now it is working.
本文标签: wp cronRun function at a specific time of a day
版权声明:本文标题:wp cron - Run function at a specific time of a day 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749042192a2307306.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论