• CRON: add a new task

    Read more

    Set a timing interval

    add_filter( 'cron_schedules', 'dev__set_interval' );
    function dev__set_interval( $schedules ) {
    	$schedules['dev__interval__5_minutes'] = array(
    		'interval'	=> 60 * 5,
    		'display'	=> 'Every 5 Minutes'
    	);
    	return $schedules;
    }

    Check if the CRON task already exists

    if ( ! wp_next_scheduled( 'dev__a_cron_thing' ) ) {
        wp_schedule_event( time(), 'dev__interval__5_minutes', 'dev__a_cron_thing' );
    }

    Add action to that new hook

    add_action( 'dev__a_cron_thing', 'dev__a_cron_thing__fallback' );
    
    function dev__a_cron_thing__fallback() {
    
    ...
    
    }