Custom starters
Ship your own starters with a theme or plugin as JSON files in .temper/scaffolds.
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:
{
"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#
| Key | Required | What it is |
|---|---|---|
label | Yes | The starter's name in the dialog. |
description | No | One line under the name. |
files | Yes | An object of file path to file content. Both can use placeholders. |
fields | No | The fields the dialog asks for. Without it, the dialog asks for Name (title, required) and Slug (slug). |
snippets | No | Loaders to add to the project's main file. See Snippets. |
kinds | No | ["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#
| Key | What it does |
|---|---|
name | The placeholder name: letters, digits and underscores, starting with a letter or underscore, such as button_text or column_2. |
label | The field's label. Required fields get "(required)" after it. |
type | text (the default), textarea, select or color. |
options | For select: a list of strings to choose from. |
default | The value used when the field is left empty. |
required | true to refuse to create the starter while the field is empty. |
placeholder | Example text shown in an empty text field. |
help | A line of help under the field. |
Placeholders#
Write placeholders as {{name}}. Spaces inside the braces are fine: {{ title }}.
| Placeholder | Value |
|---|---|
{{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:
| Snippet | Adds |
|---|---|
blocks | Registers every block in /blocks (each blocks/*/block.json). |
inc | Loads every PHP file in /inc. |
elementor | Registers every Elementor widget in /widgets. |
bricks | Registers every Bricks element in /elements. |
For example, a block starter:
{
"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 liketheme:section(fromsection.json). Pro