How to execute wp_schedule_event event on custom time interval in wordpress
For add new time interval we need to first register it.
// Here i register for every two minutes
// Here i register for every two minutes
function
add_every_two_minutes(
$schedules
) {
$schedules
[
'every_two_minutes'
] =
array
(
'interval'
=> 120,
'display'
=> __(
'Every 2 Minutes'
,
'textdomain'
)
);
return
$schedules
;
}
add_filter(
'cron_schedules'
,
'add_every_two_minutes'
);
Now we can use it as below
wp_schedule_event( time(),
'every_
two
_minutes'
,
'cron_function_for_execute'
);
Comments
Post a Comment