I have a problem because I try to run my function every minute…
And there are my two codes which I tried:
function my_cron_schedules($schedules){
if(!isset($schedules("61sec"))){
$schedules("61sec") = array(
'interval' => 61,
'display' => __('Every 61 sec'));
}
return $schedules;
}
add_filter('cron_schedules','my_cron_schedules');
add_action('wp','setup_schedule');
function setup_schedule() {
if (!wp_next_scheduled('expire_ogl') ) {
wp_schedule_event( current_time('timestamp'), '61sek' , 'expire_ogl');
}
}
add_action( 'expire_ogl', 'expire_ogl_now' );
function expire_ogl_now() {
update_post_meta(1,'now',date());
}
I tried to do also this:
add_action('wp','setup_schedule');
function setup_schedule() {
if (!wp_next_scheduled('expire_ogl') ) {
wp_schedule_event( current_time('timestamp'), 'every_minute' , 'expire_ogl');
}
}
add_action( 'expire_ogl', 'expire_ogl_now' );
function expire_ogl_now() {
update_post_meta(1,'now',date());
}
But when I check planned schedules – I get always that it will be runed every hour (even If I set ’61sec’ or ‘every_minute’. Can somone help me? Thank you in advance.