WordPress

How to Add a Custom Cron Interval in WordPress

For its cron functionality, WordPress has three defined intervals, but you can also add your own. Here's how to do it.

Table of Contents

If you purchase through a link on our site, we may earn a commission.

For its cron functionality, WordPress has three defined intervals:

  • Hourly
  • Twicedaily
  • Daily

However, you can also create your own interval as follows (weekly as an example):

[php]
add_filter( ‘cron_schedules’, ‘cron_add_weekly’ );

function cron_add_weekly( $schedules ) {
// Adds once weekly to the existing schedules.
$schedules[‘weekly’] = array(
‘interval’ => 604800, // 60*60*24*7
‘display’ => __( ‘Once Weekly’ )
);
return $schedules;
}

[/php]

If you enjoyed this post, make sure to subscribe to WP Mayor’s RSS feed.

Jean Galea is an investor, entrepreneur, and writer. He is the founder of WP Mayor, and the plugins WP RSS Aggregator and Spotlight. He also runs AgentVania. Connect with him on X or LinkedIn, or visit jeangalea.com.

If you purchase through a link on our site, we may earn a commission.

More from Our Blog

Get the Monthly Showcase

One email a month, written by me, with the best of the last month’s editorial work and some stuff you won’t find anywhere else.

Stay curious and keep building.

Mark from WP Mayor