Schedules a hook which will be executed by the WordPress actions core on a specific interval, specified by you. The action will trigger when someone visits your WordPress site, if the scheduled time has passed.

In this tutorial, I’ll show you how you create an event that will be executed once hourly, or daily, etc.

Usage:

<?php wp_schedule_event(time(), ‘hourly’, ‘my_schedule_hook’); ?>

Schedule an hourly event

To schedule an hourly event in a plugin, call wp_schedule_event on activation (otherwise you will end up with a lot of scheduled events!):

add_action(‘my_hourly_event’, ‘do_this_hourly’);

function my_activation() {
wp_schedule_event(time(), ‘hourly’, ‘my_hourly_event’);
}

function do_this_hourly() {
// do something every hour
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here