Temper
Menu

Custom starters

Ship your own starters with a theme or plugin as JSON files in .temper/scaffolds.

On this page

A theme or plugin can carry its own starters, so everyone who works on it starts new pieces the same way. Each starter is one JSON file in .temper/scaffolds/ inside the project. They appear in the editor's New dialog under From this theme, next to the built-in starters.

Custom starters work in Temper and Temper Pro alike.

A first starter#

Save this as .temper/scaffolds/section.json in your theme:

JSON
{
  "label": "Section",
  "description": "A full-width section pattern with a heading.",
  "fields": [
    { "name": "title", "label": "Name", "type": "text", "required": true, "placeholder": "Call to action" },
    { "name": "slug", "label": "Slug", "type": "text", "help": "Leave empty to generate from the name." },
    { "name": "tone", "label": "Background", "type": "select", "options": ["base", "contrast", "accent"], "default": "base" }
  ],
  "files": {
    "patterns/{{slug}}.php": "<?php\n/**\n * Title: {{title}}\n * Slug: {{namespace}}/{{slug}}\n * Categories: featured\n */\n?>\n<!-- wp:group {\"align\":\"full\",\"backgroundColor\":\"{{tone}}\",\"layout\":{\"type\":\"constrained\"}} -->\n<div class=\"wp-block-group alignfull has-{{tone}}-background-color has-background\">\n<!-- wp:heading -->\n<h2 class=\"wp-block-heading\"><?php esc_html_e( '{{title}}', '{{textdomain}}' ); ?></h2>\n<!-- /wp:heading -->\n</div>\n<!-- /wp:group -->\n"
  }
}

Save the file, click New, and Section is there. Its fields appear in the dialog, and Create writes patterns/<slug>.php with the placeholders filled in.

The file format#

KeyRequiredWhat it is
labelYesThe starter's name in the dialog.
descriptionNoOne line under the name.
filesYesAn object of file path to file content. Both can use placeholders.
fieldsNoThe fields the dialog asks for. Without it, the dialog asks for Name (title, required) and Slug (slug).
snippetsNoLoaders to add to the project's main file. See Snippets.
kindsNo["theme"] or ["plugin"] to offer the starter for one kind of project only. Without it, the starter is offered in both.

A file that isn't valid JSON, or has no label or files, is skipped.

Fields#

KeyWhat it does
nameThe placeholder name: letters, digits and underscores, starting with a letter or underscore, such as button_text or column_2.
labelThe field's label. Required fields get "(required)" after it.
typetext (the default), textarea, select or color.
optionsFor select: a list of strings to choose from.
defaultThe value used when the field is left empty.
requiredtrue to refuse to create the starter while the field is empty.
placeholderExample text shown in an empty text field.
helpA line of help under the field.

Placeholders#

Write placeholders as {{name}}. Spaces inside the braces are fine: {{ title }}.

PlaceholderValue
{{title}}The title field, as typed.
{{slug}}The slug field, or the title when it's empty, in lowercase with dashes, like call-to-action.
{{textdomain}}The project's text domain.
{{namespace}}The text domain as a slug, for block and pattern names, like my-theme.
{{prefix}}The namespace with underscores, for PHP function names, like my_theme.
{{any_field}}The value of any field you defined.

A placeholder Temper doesn't know is left as it is.

Warning

The slug can't be empty. Keep a title or slug field in your starter, or Temper refuses with "Enter a name using letters or numbers."

Snippets#

Some code needs a loader in the file WordPress boots the project from: functions.php in a theme, the main file in a plugin. List the loaders your starter needs in snippets, and Temper adds each one once:

SnippetAdds
blocksRegisters every block in /blocks (each blocks/*/block.json).
incLoads every PHP file in /inc.
elementorRegisters every Elementor widget in /widgets.
bricksRegisters every Bricks element in /elements.

For example, a block starter:

JSON
{
  "label": "Card block",
  "description": "A dynamic card block rendered by PHP.",
  "files": {
    "blocks/{{slug}}/block.json": "{\n\t\"$schema\": \"https://schemas.wp.org/trunk/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"{{namespace}}/{{slug}}\",\n\t\"title\": \"{{title}}\",\n\t\"category\": \"theme\",\n\t\"render\": \"file:./render.php\"\n}\n",
    "blocks/{{slug}}/render.php": "<div <?php echo get_block_wrapper_attributes(); ?>>\n\t<?php esc_html_e( '{{title}}', '{{textdomain}}' ); ?>\n</div>\n"
  },
  "snippets": ["blocks"]
}

Rules#

  • Every file a starter creates passes the save checks, like any other write. A file that fails stops the starter.
  • A starter never overwrites a file. If one exists, Temper asks for a different slug.
  • With an AI key, the Describe what it should do field works for custom starters too.
  • AI assistants see custom starters in list_templates, with ids like theme:section (from section.json). Pro