How to schedule Exports with WP Crontrol
What is needed: Simply Static, WP-Crontrol
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
Wp-Crontrol is a powerful plugin for visually managing cron jobs within WordPress. Install and activate it, then navigate to Tools->Cron Events.
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, choose a recurrence (interval), and click “Add Event”.
In this example, I used “my_simply_static_cron_event” as the event name and decided to run the event hourly.
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(); $simply_static->run_static_export(); }
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: