Release Notes: Dynamic Block Pattern Category Registration
New Features:
Automatic Pattern Category Registration
- The theme now automatically registers block pattern categories based on subfolders in the
patterns/
directory. - How it works:
- Any subfolder you add to
patterns/
(e.g.,patterns/cards/
,patterns/hero/
) will be registered as a block pattern category. - The folder name is used as the category slug, and a human-friendly label is generated for the block editor.
- Pattern files placed in these subfolders and using the correct
Categories
header (matching the folder name) will appear in the block editor under the appropriate category.
- Any subfolder you add to
- No manual code changes are needed to add new pattern categories—just add a subfolder to
patterns/
. - How to use:
- Create a new subfolder inside
patterns/
(e.g.,patterns/cards/
). - Place your pattern PHP files in that subfolder.
- In each pattern file, set the
Categories
header to the folder name (e.g.,Categories: cards
). - The new category will appear in the block editor, and your patterns will be listed under it.
- Create a new subfolder inside
Flush Object Cache and Transients
- Added a "Flush Object Cache and Transients" button to the Theme Options page (Tools > WDSBT Settings).
- When used, this button:
- Unregisters all custom block patterns and re-registers pattern categories.
- This would not force a full rescan of the
/patterns
folder which would automatically show the new pattern category. - Switching themes is the only 100% reliable way to force a full re-scan of the
/patterns
folder. - Flushing all caches and transients, and hard refreshing, are the next best options.
- There is no official WordPress function to force this without a theme switch.
- This would not force a full rescan of the
- Flushes the WordPress object cache and deletes all transients to help ensure new code and/or style changes appear as soon as possible in the block editor.
- Injects a JavaScript event to notify open block editor tabs to refresh their pattern/category cache.
- Displays a clear admin notice explaining WordPress’s caching limitations and that a theme switch or full cache clear may still be required for new categories to appear immediately.
- Unregisters all custom block patterns and re-registers pattern categories.
- How to use:
- Add or update patterns/categories in your theme’s
/patterns
folder. - Go to Tools > WDSBT Settings in the WordPress admin.
- Click the "Flush Object Cache and Transients" button.
- Reload the block editor to see new patterns/categories, or follow the admin notice instructions if they do not appear immediately.
- Add or update patterns/categories in your theme’s
Important:
Due to WordPress core caching, new pattern categories may not appear immediately after a flush.
If you do not see your new categories:
- Try switching to another theme and then back to your theme, or
- Wait several minutes for caches to expire, or
- Clear all object caches and browser caches.
This is a WordPress limitation and does not affect production sites where patterns/categories are set before launch.