apply_filters( 'cron_schedules', array $new_schedules )

Filters the non-default cron schedules.


Description Description


Parameters Parameters

$new_schedules

(array) An array of non-default cron schedules. Default empty.


Top ↑

Source Source

File: wp-includes/cron.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Dominik Schilling

    Add a custom cron schedule for every 5 minutes:

    /**
     * Adds a custom cron schedule for every 5 minutes.
     *
     * @param array $schedules An array of non-default cron schedules.
     * @return array Filtered array of non-default cron schedules.
     */
    function devhub_custom_cron_schedule( $schedules ) {
    	$schedules[ 'every-5-minutes' ] = array( 'interval' => 5 * MINUTE_IN_SECONDS, 'display' => __( 'Every 5 minutes', 'devhub' ) );
    	return $schedules;
    }
    add_filter( 'cron_schedules', 'devhub_custom_cron_schedule' );
    
  2. Skip to note 2 content
    Contributed by dhl17

    custom cron schedule for every 10 & 15 Seconds

    function custom_cron_job_recurrence( $schedules ) 
    {
    	if(!isset($schedules['10sec']))
    	{
    		$schedules['10sec'] = array(
    			'display' => __( 'Every 10 Seconds', 'twentyfifteen' ),
    			'interval' => 10,
    		);
    	}
    	
    	if(!isset($schedules['15sec']))
    	{
    		$schedules['15sec'] = array(
    		'display' => __( 'Every 15 Seconds', 'twentyfifteen' ),
    		'interval' => 15,
    		);
    	}
    	
    	return $schedules;
    }
    add_filter( ‘cron_schedules’, ‘custom_cron_job_recurrence’ );
    

You must log in before being able to contribute a note or feedback.