add custom cron in wordpress

Posted: August 3, 2015 in Uncategorized
Tags: , ,

following code will run at every 15 minutes.

if you want to use while loop inside cron function,you need to check every function inside wp_query.some times global $post variable not worked 😦

add_filter(‘cron_schedules’, ‘add_scheduled_interval’);

// add once 5 minute interval to wp schedules
function add_scheduled_interval($schedules) {
$schedules[‘minutes_my’] = array(‘interval’=>300, ‘display’=>’Once 5 minutes’);
return $schedules;
if (!wp_next_scheduled(‘minutes_my_cron’)) {
wp_schedule_event(time(), ‘minutes_my’, ‘minutes_my_cron’);
add_action(‘minutes_my_cron’, ‘min_cron_executor’);

function min_cron_executor() {

//add CODE




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s