WordPress ships with three WP-Cron intervals: hourly, twicedaily, and daily. If you need a different interval (e.g. every 5 minutes), add the following code. For more on WordPress hooks and filters.
add_filter( 'cron_schedules', function( $schedules ) {
$schedules['every_five_minutes'] = array(
'interval' => 300,
'display' => 'Every 5 Minutes',
);
return $schedules;
} );
// Schedule the event on theme activation
if ( ! wp_next_scheduled( 'my_custom_cron_event' ) ) {
wp_schedule_event( time(), 'every_five_minutes', 'my_custom_cron_event' );
}
add_action( 'my_custom_cron_event', function() {
// Your code here
} );