Weekly and Monthly WP-Cron Schedules
Adds "Once Weekly" and "Once Monthly" recurrences to WP-Cron so your own scheduled tasks, or plugins that offer a schedule picker, can run less often than daily.
Opens WPIDE on
Code
add_filter( 'cron_schedules', function ( $schedules ) {
$schedules['wpide_weekly'] = array(
'interval' => WEEK_IN_SECONDS,
'display' => __( 'Once Weekly' ),
);
$schedules['wpide_monthly'] = array(
'interval' => MONTH_IN_SECONDS,
'display' => __( 'Once Monthly' ),
);
return $schedules;
} );
Notes
Use the keys "wpide_weekly" and "wpide_monthly" with wp_schedule_event(); WordPress 5.4+ already has "weekly", which this keeps untouched.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.