Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Theme pattern files are not registered until the pattern cache is cleared

Open
#5,158 3 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@chubes4 is already working on this.

Since Oct 16, 2026.

  • #5159 by @chubes4 — closed without merging

Assessment

This issue has not been assessed yet.

Description

What happens

A pattern file added to a theme's patterns/ directory is not registered on a Studio site. It stays missing across page loads and WP-CLI runs until the theme's pattern cache is cleared.

This affects anyone developing a block theme in Studio, and Studio Code in particular: the agent scaffolds and edits themes, adds a pattern, and then cannot find it in the block pattern registry.

Why

Since WordPress 6.4, WP_Theme::get_block_patterns() caches the theme's pattern file data in a transient. It only bypasses the cache when the site is in theme development mode (wp_is_development_mode( 'theme' )).

Studio sites define WP_ENVIRONMENT_TYPE as local, but leave WP_DEVELOPMENT_MODE empty, so the cache is used.

Reproduce

On a fresh Studio site running Twenty Twenty-Five:

  1. Load the front page once.
  2. Add wp-content/themes/twentytwentyfive/patterns/repro.php with the header Slug: twentytwentyfive/repro.
  3. Run studio wp eval 'var_dump( WP_Block_Patterns_Registry::get_instance()->is_registered( "twentytwentyfive/repro" ) );', which prints false. It's still false after more page loads.
  4. Run studio wp eval 'wp_get_theme()->delete_pattern_cache();', and the check from step 3 prints true.

wp_get_development_mode() returns an empty string on the site.

Suggested fix

In packages/common/lib/mu-plugins.ts, next to the existing WP_ENVIRONMENT_TYPE default, define the development mode when the site has not set it:

if ( ! defined( 'WP_DEVELOPMENT_MODE' ) ) define( 'WP_DEVELOPMENT_MODE', 'theme' );

That snippet runs before wp-settings.php, so it takes effect for both page loads and WP-CLI. Theme development mode is what core provides for local theme work. It also skips the theme.json cache, which helps for the same reason.

A narrower alternative is for Studio Code's file tools to call wp_get_theme()->delete_pattern_cache() after writing to a theme's patterns/ directory. That only covers the agent, though, not people editing themes by hand.

How this was found

In an eval run of the Studio Code agent, it added a slideshow pattern to the theme it had scaffolded. It then spent about 10 tool calls working out why the pattern wasn't registered.


Investigated and drafted with AI assistance (Claude, running in the Pi coding agent): the agent traced the eval transcript, read the WordPress core caching path, and ran the reproduction above on a throwaway Studio site. Reviewed by the author before posting.

Dominant language
TypeScript
Stars
543
Forks
104
Avg merge
23h 59m
Merged PRs (30d)
276

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/studio

All issues in Automattic/studio

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.