This is a collection of useful code snippets that can be used to achieve certain things in Simply Static. Some of them will be included in Simply Static in the future, others will stay as a code snippet.
Table of Contents
Fire webhook after static export
You can use the following code snippet to send a request to an external service. I also added authentication as it’s needed for some services (GitHub, for example):
Run simply static with WP-Cron
This code snippet can be used to run different kinds of exports with Simply Static without touching the UI at all.
Single Static Export after publishing a post
You may want to simplify your publishing workflow by automatically exporting a single page/post after you hit the publish button. Usually, this is done by clicking the “Export static” button within a post, but you can entirely automate that with the following code snippet:
Add URLs with a specific shortcode in Single Exports
When updating your static website you will most likely use Single Exports to push new content. Single Exports automatically include the homepage, blog page, archive-, tag-, and category pages of the exported post.
You may want to extend that list with all posts that contain a specific shortcode (maybe you have a recent posts shortcode or something similar). The following code snippet will do exactly that, just replace [your-shortcode] with your own shortcode.