📝 Fix Block Patterns Registering Twice After a Theme Switch
A block pattern registered via register_block_pattern() in both a parent theme’s functions.php and a child theme that extends it (a common copy-paste-and-modify mistake when customizing a starter theme) ends up registered under the same pattern slug twice — WordPress doesn’t error on the duplicate registration, but the pattern then shows up twice in the inserter, and editors have no way to tell which of the two identical-looking entries is the one actually being maintained going forward.
🔎 The Problem
// parent-theme/functions.php
register_block_pattern('mytheme/hero-banner', $args);
// child-theme/functions.php (meant to override, but copy-pasted
// instead of using unregister_block_pattern() first)
register_block_pattern('mytheme/hero-banner', $modified_args);
// Result: pattern appears TWICE in the inserter under the same name
✅ Fix: Unregister Before Re-Registering, Don’t Just Add Again
- In the child theme, call
unregister_block_pattern('mytheme/hero-banner')before registering the modified version, so the override actually replaces the parent’s pattern instead of sitting alongside it. - Hook both the unregister and re-register calls to
initwith a priority that guarantees the child theme’s code runs after the parent’s registration has already happened. - Audit
functions.phpin both parent and child themes for everyregister_block_pattern()call and confirm each slug appears exactly once across the two files combined.
A child theme is supposed to override its parent, not just add another voice saying the same thing twice.





