Patterns

Patterns are one of the most useful tools for theme development, allowing you to reuse groups of blocks across a wide variety of scenarios. Over time, you will likely use patterns more than any other theme feature available in WordPress.

In this chapter, you will learn what patterns are and dive into the various use cases where you will apply them in your themes. This will include everything from providing insertable layouts to your theme users to running PHP for loading assets and even more.

Navigating this chapter

Use the following links to locate a specific topic within this chapter. It’s best to read them in order, but if you are already familiar with the basic tenets of pattern development, feel free to jump to the topic that you’re looking for.

  • Introduction to Patterns: Provides an overview of what patterns are and how they work, giving you a foundation for later articles in the chapter.
  • Registering Patterns: A guide on registering/unregistering patterns and pattern categories for your theme.
  • Using PHP in Patterns: How and why to use PHP in your themes, including practical applications like internationalizing text and including media.
  • Usage in Templates: How to include patterns in templates and why you should use them over templates in many cases.
  • Block Type Patterns: A walkthrough of creating block-specific patterns that offer a more elegant experience for your theme users.
  • Starter Patterns: Building custom patterns as starting points for creating starting points for your theme users to build their pages and templates.
  • Patterns and Block Locking: How to use the Block Locking API to curate the editing experience for your theme users.