Scheduled Cron Job in wordpress

if (!wp_next_scheduled('my_task_hook')) {

    wp_schedule_event(time(), 'hourly', 'my_task_hook');


add_action('my_task_hook', 'my_task_function');

function my_task_function() {

    wp_mail('nileshyadav326@gmail.com', 'Automatic email', 'Automatic scheduled email from WordPress.');

}

1 comment:

  1. Your Blog is amazing. If you want to know that HOW TO SETUP A CRON JOB then,
    Click here for more information:
    HOW TO SETUP A CRON JOB

    ReplyDelete