Creating patterns

“Pattern” covers six different jobs in WordPress, and the job decides most of the mechanics: where the pattern can be stored, which headers place it, and whether it appears in the inserter. Pattern Builder’s Create Pattern dialog starts from the job.

The Create Pattern dialog

Create Pattern, on the Pattern Builder screen, opens a dialog with the kinds listed down the left under two headings, Design and Starter, and the chosen kind’s description and fields on the right. Every kind takes a name and a description. Beyond that, the dialog asks only for what the kind leaves open: a design pattern asks where to store it, a page pattern which post types it is for, and so on. The same dialog is reachable from the Pattern Builder sidebar in the editor, where the two panes become two screens.

A kind is a starting point, not a stored property. Nothing in the file records “this is a page pattern”; the kind simply fills in the metadata its job implies, and all of it stays editable afterwards in the pattern’s own panels.

Design

Design Pattern

Insert it anywhere, then edit freely. The building blocks of a site: blocks put together in a way worth reusing. Inserting one copies the markup, the copy is yours to change, and editing the pattern later affects only new insertions.

  • Unsynced.
  • Asks where to store it: Theme (a file) or User (the database). It is the only kind that asks.
  • No placement headers; it simply appears in the inserter.

Synced Design Pattern

Content is editable, design is locked. The same building-block job, but instances reference the pattern instead of copying it. Editing the pattern changes it everywhere it is used; an instance can change only the content of the slots the pattern exposes.

  • Synced. For a theme pattern that is the Synced: yes header.
  • Asks where to store it, Theme or User.
  • As a theme pattern it needs the runtime described on Synced theme patterns, which is also where content slots are explained.

Starter

The four starter kinds are the patterns WordPress offers at a particular moment: when a page is created, when a block is inserted, when a template or template part is created. Each is placed by a header in the pattern file, so starter patterns are always theme patterns; a database pattern has nowhere to record where it should be offered.

Page Pattern

Offered when new content is created. What WordPress shows in the “choose a pattern” dialog when someone starts a new page. Often an assembly of design patterns with this pattern supplying the words.

  • Writes Block Types: core/post-content, which is what makes WordPress offer it for new content.
  • Asks which post types it is for; pages by default.

Block Starter Pattern

Offered when a block is inserted. Belongs to a block type. WordPress offers it when that block is inserted and still empty, so an untouched Query Loop or Cover asks which design to start from, and from the block’s toolbar, to swap one design for another.

  • Asks which block types it belongs to. The picker talks in block titles and offers everything registered on this site; a name typed straight in is kept too, since a pattern may name a block this site does not have.
  • Writes those names into Block Types.

Template Pattern

Offered when a template is created. A whole template, header and footer included, offered in the Site Editor when someone creates a template of that type: an archive, a home page, a 404.

  • Asks which template types it is for, from WordPress’s own list.
  • Writes Template Types, sets Inserter: no because a whole template is noise in the block inserter, and a 1400px Viewport Width since it previews as a full page.

Template Part Pattern

Offered for a header or a footer. Belongs to a template part. The Site Editor offers it when a header or footer is created, and from the part itself to swap designs.

  • Asks which part it is for: Header or Footer. WordPress supports those two areas only.
  • Writes Block Types: core/template-part/header (or footer) with the matching Categories entry, and a 1400px viewport width.

Choosing a kind

You want…KindWhat it fixes
a section to drop in and editDesign Patternunsynced; theme or database
a component whose design stays consistent everywhereSynced Design PatternSynced: yes; theme or database
a starting layout for new pagesPage PatternBlock Types: core/post-content plus Post Types
a design for an empty Query Loop, Cover, and so onBlock Starter PatternBlock Types: <that block>
a whole archive, 404 or home layoutTemplate PatternTemplate Types, Inserter: no, wide viewport
a header or footer designTemplate Part PatternBlock Types: core/template-part/header|footer

After creating: the panels

The new pattern opens in the editor. Add its blocks there, and use the Pattern Builder sidebar to adjust anything the kind decided:

  • Pattern Metadata — Name, Slug, Description, Categories, Keywords and Viewport Width.
  • Starter Patterns — Block Types, Post Types, Template Types and Available in Inserter. Turning a design pattern into a page pattern later is a matter of adding core/post-content here.
  • Synced status — Synced or Unsynced.
  • Pattern Bindings — on a synced pattern, name the blocks that instances may fill; the content slots.
  • Pattern Source — convert between theme and user, and upload to the cloud when connected.

Other ways in

WordPress’s own routes still work. Select blocks in any editor and choose Create Pattern, and the result appears under User in Pattern Builder, where it can be converted to a theme file. Drop a PHP file into the theme’s patterns directory and it appears under Theme. And an agent can store finished markup through the create-pattern ability.