WP-Cron tasks scheduled but not running

First can you please confirm that you don’t have any caching plugins enabled? Caching plugins can interfere with cron jobs because your visitors are not served a live page but a cached version of your page. If you have a caching plugin enabled, you can choose one of your pages, add an exclusion to your … Read more

Where in the page load code is wp-cron triggered?

The WordPress cron is run by the wp_cron() function, which is hooked to run on the init hook, which runs on every page load. wp_cron() is defined in wp-includes/cron.php and hooked in wp-includes/default-filters.php. The wp_cron() function kicks off a wp_remote_post() request to /wp-cron.php. Some server configurations prevent scripts sending a request to the same domain … Read more

How to set up WP Cron in this scenario

First things first: Say hello! to $wpdb The wpdb Class is what you take to interact with the database on it’s most basic level. Forget all those mysql_* functions, when it comes to WordPress. The core has a nice wrapper, that makes most things pretty safe for you (hint: SQL-injections and other bad boys). Or … Read more

Managing scheduled tasks

It looks to me that this line add_action(‘obr_scheduled_task’, array(&$this, ‘obr_activate_scheduled_task’)); should be add_action(‘obr_scheduled_task’, array(&$this, ‘obr_scheduled_task’)); otherwise you are re-scheduling on every page visit. Edit: Here is a logger that can be useful when debugging wp-cron: function my_logger($var){ $logfile=”/tmp/logger.txt”; // EDIT this to your needs file_put_contents($logfile, date(“Y-m-d: H:i:s”,time()).” — “.print_r($var, true).”\n”, FILE_APPEND); } You can use … Read more

what is firing cron

Well, it isn’t the best tutorial I’ve came across, so I get why you’re confused… Smashing Magazine has a little bit better tutorial on this subject. Some quotes from this article that should help you understand how does WP Cron work… WordPress Cron is what many people refer to as a “pseudo-cron system.” The difference … Read more

Run a cron job (or similar) in the background of WP after post update/create

Alright, here’s some code I just whipped up. Completely untested, just wrote it right off the cuff…so don’t expect it to work 100% when you drop it in, but the core concept is there, as is a decent amount of the legwork add_action( ‘my_filter_posts_content’, ‘my_filter_content’ ); add_action( ‘save_post’, ‘my_set_content_filter’ ); if( !wp_next_scheduled( ‘my_filter_posts_content’ ) ) … Read more