How to remove WordPress default block patterns?

Where do these block patterns come from?” – That is a common question for my block theme development course students.

To explain: this is what you see when you explore the block patterns in the Twenty Twenty and Twenty Twenty One themes:

A screenshot of the Explore Patterns dialogue in the Twenty Twenty theme showing the default block patterns.
Default block patterns in the Twenty Twenty theme.
A screenshot of the Explore Patterns dialogue in the Twenty Twenty-One theme showing the default block patterns.
Default block patterns in the Twenty Twenty One theme

You see that these are the exact same sets of block patterns. How can this be?

Where are these block patterns coming from?

Themes can have their own block patterns, so that’s on obvious source. But the WordPress project also has their own set of block patterns. And it offers these to the community through the WordPress.org Block Pattern Directory.

A screenshot of the WordPress Block Pattern Directory.
The welcome page of the WordPress Block Pattern Directory.

The Block Pattern Directory is a collection of pre-designed block patterns. Every community member can design their own patterns, and contribute them to the Directory. The idea is to provide users with a variety of ready-made designs to choose from.

But the issue is that WordPress shows these block patterns from the Directory in the same way as the patterns provided by the theme.

As you can imagine, these generic patterns are not a great fit for most, if not all, sites. Therefore removing them is one of the first things I do whenever I create a new theme.

How to remove the default block patterns?

To prevent the loading of patterns from the WordPress.org Pattern Directory, you can use the should_load_remote_block_patterns filter:

add_filter( 'should_load_remote_block_patterns', '__return_false' );

So far so good, but now the first pattern shown is a weird looking (at least in Twenty Twenty One) button pattern.

A screenshot of the Explore Patterns dialogue in the Twenty Twenty-One theme showing default block patterns from WordPress Core.
These patterns are not from the theme or the Directory.

So this is also not a theme pattern, but a Core pattern. For historic reasons, WordPress ships with a handful of patterns that are enabled by default.

To get rid of these, we need to remove the core-block-patterns theme support:

function wpdc_remove_core_block_patterns_support() {
    remove_theme_support( 'core-block-patterns' );
}
add_action( 'after_setup_theme', 'wpdc_remove_core_block_patterns_support' );

Now only the patterns provided by the theme remain:

A screenshot of the Explore Patterns dialogue in the Twenty Twenty-One theme showing only block patterns from the theme.
All these patterns are from the theme, and fit with the design.

Why removing default patterns is a must

As you can see all this takes is a few lines of code. But adding this code is crucial if you are building websites for clients. Because it’s easy for the client to get overwhelmed with the sheer number of patterns.

A key part of your work is to adapt WordPress to the needs of your client. Which means removing all the options that are not relevant.

Fränk Klein Avatar