It is a time-based schedule task of cron job with a practical WordPress. WordPress has core features some time need to update. If likely post update, schedule post, and time base image changes. WordPress corn job name comes from the UNIX system. It is a system software mainly used for time-based scheduling systems for uses many purposes.It is mainly used for time-based working like page/post content update or page load and schedule tasks.
add_filter('corn_schedules', 'adding_new_cron_schedule'); function adding_new_cron_schedule($schedules){ $schedules['ten_seconds'] = array( 'interval' => 10, 'display' => _e('Every Ten Second') ); return $schedules; }
You must create a new hook for this task. Which give hook name and function name. Next, you get the hook name and call it your custom function. You can give it any name. This calling function will be executing what you run here.
Before saying that, it is a time-based scheduling system. example( If we set our time-based 5 min after every interval. If you measure time 2:05 then the next time will be 2:10 after 2:15 ). This time change repeatedly because we setup it 5 min after changing everything. This is the best WP cron job with a practical session.There are several default intervals of WordPress.
add_action("my_corn_custom_data","my_custom_method_cron_job"); function my_custom_method_cron_job( $args= [ 'post_title'=>'Creat a new title for every 10 second', ]; wp_insert_post($args); )
WordPress corn is a simple time-based task scheduler. We already know. WP-corn schedule gives us a function. Which are three-parameter.
WP_schedule_event( time(), 'ten_seconds', 'my_corn_custom_data' );
1. $timestamp – It is a UNIX timestamp
2. $recurrence – Interval time which use for recur in second
3. $hook – It is a custom hook
Finally, we check the error, and the task is not already scheduled. If you need help please feel free to contact us.
if(!WP_schedule_event('my_corn_custom_data')){
WP_schedule_event( time(), 'ten_seconds', 'my_corn_custom_data' );
}