Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

All docs

Generators

A generator makes a snippet from a short form: fill in a post type's name, a list of redirects or a Google Analytics ID, and you get a working snippet with readable code. The form stays with the snippet as its settings form, so you can change the values later without touching the code, or edit the code yourself.

Open the generators

In the editor, click + New → From a generator…, or Generators at the bottom of the sidebar.

The screen lists the generators in groups. Search generators… finds one by its words. Each card shows the snippet type it makes, and a note if it Needs WooCommerce. or Needs Snipfire Pro.

To link straight to one, add #/generators/ and its ID to the editor's address, for example admin.php?page=snipfire#/generators/post-type.

Make a snippet

  1. Click Use on a generator. A new snippet opens on its Settings form tab, named after the generator, with notes in its description.
  2. Fill in the form. The Code tab shows the code the form feeds.
  3. Switch it on (Active) and click Save. The code is checked and your site test-loaded, as for any snippet. See How Snipfire keeps your site safe.

Generated snippets go in the folder Generated with the tag generator. Nothing is saved until you click Save.

Change it later

Open the snippet: it opens on its form. Change the values and save. The code reads them each time it runs (as $settings in PHP and {setting:key} in HTML and JavaScript), so you don't need to touch it.

You can also edit the code like any snippet's, for example to add an argument the form doesn't have. The form keeps working as long as the code reads its values.

The generators

The ID is for WP-CLI and links.

Content

Generator ID Makes
Custom post type post-type A new kind of content, like Books or Projects, with its own menu, editor and archive (PHP)
Custom taxonomy taxonomy A new way to group content, like Genres for books (PHP)

New or changed addresses work straight away: you don't need to visit Settings → Permalinks. Don't change a post type's key once it has content: the posts stay under the old key.

Theme

Generator ID Makes
Widget area sidebar A new widget area for Appearance → Widgets, shown anywhere with its shortcode (PHP)
Image size image-size An extra image size for every upload, optionally offered in the editor's image size menu (PHP)
Menu location menu-location A place for a navigation menu (Appearance → Menus), shown anywhere with its shortcode (PHP)

Widget areas and menu locations are for classic themes: block themes have no Widgets or Menus screen. A new image size only applies to new uploads; regenerate thumbnails for existing images (for example with wp media regenerate).

Admin

Generator ID Makes
Admin menu item admin-menu A menu item in the admin: a link, or a page with your own text, for the people you choose (PHP)

Tools

Generator ID Makes
Scheduled task cron-event Runs your code hourly, twice a day, daily or weekly with WP-Cron. Write the task itself in the Code tab (PHP)
Redirects redirects Sends old addresses to new ones: 301, 302, 307 or 308, optionally keeping the query string (PHP)

WP-Cron runs when someone visits the site. For exact times on a quiet site, have the server call wp-cron.php (ask your host).

Structured data (schema)

Generator ID Makes
Schema: Organization schema-organization Who is behind the site (name, logo, contact, social profiles), as JSON-LD on the home page (PHP)
Schema: Local business schema-local-business Address, opening hours and contact details of a shop, office or restaurant, as JSON-LD on the home page (PHP)
Schema: FAQ schema-faq Questions and answers as FAQPage data on the pages you choose (PHP)
Schema: Article schema-article Article data on every post, filled in from the post: title, dates, author, featured image (PHP)

SEO plugins (Yoast, Rank Math, SEOPress…) often add Organization and Article data already. Check the page source first, so it isn't there twice. Put the FAQ's questions on the page itself too.

Tracking

Generator ID Makes
Google Analytics 4 google-analytics The Google tag (gtag.js) for a GA4 property on every page (HTML)
Google Tag Manager google-tag-manager The Tag Manager container: the script in the head and the noscript part after <body> opens (PHP)
Meta (Facebook) Pixel meta-pixel The Meta Pixel base code with a PageView on every page (HTML)
GA4 purchase event (WooCommerce) Pro ga4-purchase Sends each order to Google Analytics as a purchase on the order-received page, once per order (JavaScript)

With Snipfire Pro, set Cookie consent on the Analytics and Pixel snippets (Statistics and Marketing) so they wait for the visitor's consent. See Cookie consent. Tag Manager handles consent for its tags itself. The noscript part of Tag Manager needs a theme that calls wp_body_open(); most do.

The GA4 purchase event needs WooCommerce, the Google tag on the page (for example from the Google Analytics 4 generator), and Snipfire Pro for the WooCommerce order smart tags it reads. Without Pro the tags aren't replaced and the event isn't sent. Without Pro, the library snippet Google Analytics 4 purchase event (wc-ga4-purchase-event, in the More tracking codes pack) does the same job in PHP. See The snippet library.

Who can use them

Anyone who can create snippets can open the generators. With Snipfire Pro's team access, people with CSS, JS and HTML (no PHP) access can use the Meta Pixel and GA4 purchase generators. The others make PHP (the Google Analytics 4 snippet is HTML with a little PHP in it), so they need full access.

From the command line

wp snipfire generate                        # list the generators and their fields
wp snipfire generate post-type --values='{"key":"book","singular":"Book","plural":"Books"}' --active
wp snipfire generate redirects --values='{"rules":[{"from":"/old/","to":"/new/"}]}' --active
wp snipfire generate google-analytics --values='{"measurement_id":"G-ABC123"}' --title="GA4" --porcelain

Fields you leave out get their defaults. Change the values later in the editor, or with wp snipfire update <id> --values=<json>. See WP-CLI.

The generators are also in the REST API and available to AI assistants.

Something unclear or missing? Tell us