To disable the default block patterns in WordPress, so the inserter only shows the patterns of your theme and your own, remove the core-block-patterns theme feature and stop WordPress from loading patterns from WordPress.org.
That leaves the Patterns tab of a custom or blank theme clean for clients: no query loop and navigation overlay patterns from core, and no featured patterns pulled from the Pattern Directory.
The snippet
<?php
/**
* Disable the default (core) block patterns and the patterns WordPress
* loads from the WordPress.org Pattern Directory.
*/
add_action( 'after_setup_theme', 'dpc_disable_core_block_patterns' );
function dpc_disable_core_block_patterns() {
// Core registers its patterns on init only while the theme supports this feature.
remove_theme_support( 'core-block-patterns' );
}
// No patterns fetched from api.wordpress.org (featured, Directory and theme.json "patterns").
add_filter( 'should_load_remote_block_patterns', '__return_false' );
How it works
- WordPress turns the
core-block-patternsfeature on for every theme, and oninitit registers its owncore/...patterns only while that feature is on. The snippet removes the feature onafter_setup_theme, which runs beforeinit. should_load_remote_block_patternscontrols every pattern WordPress fetches from api.wordpress.org: the core keyword patterns, the featured patterns and the Directory patterns a theme lists underpatternsintheme.json. Returningfalseturns all of them off and saves the editor those HTTP requests.- Patterns from your theme’s
patterns/folder and patterns registered withregister_block_pattern()are not touched.
The older version of this post removed the theme support on init, after core had already registered its patterns, so only the remote patterns disappeared.
Add it with Scripts Organizer
In Scripts Organizer go to Code Blocks → Add New and give the block a name. Set Trigger location to Everywhere, tick PHP under Script location, paste the code into the PHP editor and publish. Leave Action/Hook empty. Patterns are registered on every request type, including the REST API calls the editor makes, so the code needs to run everywhere, not only in wp-admin.
The same code also works unchanged in a small plugin or an mu-plugin.
Customise it
- Keep the core patterns and only stop the remote ones: delete the
add_action()line and its function. - Keep the remote patterns: delete the
add_filter()line. - Remove a single pattern instead: call
unregister_block_pattern( 'core/query-grid-posts' )oninitwith a priority above 10. - Hide pattern categories you don’t use with
unregister_block_pattern_category()oninit.
Gotchas
- Synced patterns and patterns saved by users in the Site Editor are content, not registered patterns, so they stay.
- Some plugins register their own patterns; remove those with
unregister_block_pattern()and the plugin’s pattern name. - A lighter editor for single post types is a different job; see Disable Gutenberg for Specific Post Types in WordPress.
In the Scripts Organizer library Import it with one click from Scripts Organizer.