Running Simply Static with WP-Cron

Simply Static provides a simple UI to run exports of different kinds (Full Exports, Single Exports, Build Exports). It also can be executed via WP-Cron to run the static export as a background process without being limited by your server’s timeout limits.

How WP-Cron works with Simply Static

By default, each static export you start from within Simply Static is a one-time event. Once the execution is finished, it gets unscheduled from WP-Cron to keep your cron jobs low and prevent any unwanted static exports.

Wp-Crontrol – manage Crons easily

Running Simply Static with WP-Cron 1

Wp-Crontrol is a powerful plugin to visually manage your cron jobs within WordPress. Install and activate it and navigate to Tools->Cron Events.

Running Simply Static with WP-Cron 2

Create a Cron event for Simply Static

In Tools->Cron Events, click on “Add new” to create a new event. Add a name for your event and choose a recurrence (interval) for your event and click on “Add Event”. In this example, I used “my_simply_static_cron_event” as the event name and decided to run the event hourly.

Running Simply Static with WP-Cron 3

Attach the export function to your Cron event

Now that we have a cron event, the last step is adding a function to it to trigger static exports with Simply Static. Remember, we named our cron event “my_simply_static_cron_event” – that’s the hook we need to use to add our logic.

add_action( 'my_simply_static_cron_event', 'ssp_run_static_export_cron' );
 * Run a full static export daily via WP-CRON.
 * @return void
function ssp_run_static_export_cron() {
    // Full static export
	$simply_static = Simply_Static\Plugin::instance();

You can add this to the functions.php of your child theme or use the Code Snippets plugin to add it to your website.

Now Simply Static will execute a full static export every hour. You can also check that the cron job is running and scheduled correctly by searching for the event name in Tools->Cron Events like so:

Running Simply Static with WP-Cron 4