David Stockdale's Scrapcode

Scheduling Functions (Cron Jobs)

Now that I’ve created a way to compile a list of how many comments I get from various countrys I wanted to run it automatically.

When I mentioned this to the head IT guy in Tees Valley Arts he suggested I use a “cron job”.

This can be done by first adding a hook for the cron job to run.

/**
 * Adds the "cron_hook" action hook.
 * This is then called by a cron job.
 */
add_action( 'cron_hook', 'location_list_shortcode' );

Then I decided to be lazy and simply use the plugin “Advanced Cron Manager”.

Once installed it can be found under “Tools”.

There sou simply add a new event.

Then you input your hook and when it should run.

Now my list of countries I get comments from is updated daily without any input from myself!

Leave a Reply