Search
Close this search box.

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

Sponsored Ad

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 blogger. He is the founder of WP Mayor, the plugins WP RSS Aggregator and Spotlight, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.

Sponsored Ad

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

All suggestions are anonymous.

More from our blog...

Post a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Stay updated with WP Mayor's newsletter showcase every week

Stay on top of every new WordPress innovation and latest launches. Receive all our fresh product reviews and expert guides directly in your inbox.

Hosting Survey 2024

Are you happy with your hosting provider or are you over-paying for too little? Have your say below!

"*" indicates required fields

What's the main reason you picked this host?*
How happy are you with your host?*

OPTIONAL: If you'd like to receive the results of this survey, please enter your details below.