Hi Paul,
Thanks for sharing the details about your issue. It sounds like the pattern registration is working, but the child theme isn’t triggering the pattern refresh immediately in the UI.
This behavior is not typical and shouldn’t require theme switching to make the patterns appear. Here are a few things you could try:
- Clear cache: Sometimes WordPress or your browser may cache the theme files, causing changes not to appear immediately. Try clearing both WordPress and browser caches.
- Check
theme.json file: Ensure your theme.json (if you have one) includes proper configuration for patterns, as it might influence their visibility in the editor.
- Use the
register_block_pattern() function: If you’re comfortable with some PHP, you can manually register patterns using the register_block_pattern() function in your child theme’s functions.php. This ensures patterns are registered every time the theme is activated.
register_block_pattern(
'my-child-theme/my-pattern',
array(
'title' => __( 'My Custom Pattern', 'my-child-theme' ),
'description' => _x( 'A custom pattern for my theme', 'Block pattern description', 'my-child-theme' ),
'content' => '<!-- wp:group --> ... <!-- /wp:group -->',
)
);
Theme switching workaround: If the theme switch is consistently working, it could indicate a loading or refresh issue within the child theme. Investigating further may help pinpoint if something in the theme files is delaying the registration.
Hope this helps! Let me know if you need further clarification or assistance.
Thanks Mohd Javed,
I ended up setting the Development Mode to ‘theme’ in wp-config.php and that seems to have done the trick in busting the theme caching.
define( ‘WP_DEVELOPMENT_MODE’, ‘theme’ );
Regards
Paul