Kishan Jasani

Code, Creativity & Everything I Learn

How to remove WordPress default block patterns?

WordPress provides developers with the ability to manage block patterns efficiently. Here’s how you can remove default block patterns or unregister specific ones.

Removing All Default Block Patterns

To remove all default block patterns in WordPress, use the following code:

remove_theme_support( 'core-block-patterns' );

This function should be added within either the init hook or the after_setup_theme hook. For example:

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

How to remove specific block pattern?

To remove a single block pattern, use the unregister_block_pattern function. You need to specify the pattern’s prefix and slug. For example:

unregister_block_pattern( 'core/two-buttons' );

This can be used to unregister block patterns created by WordPress Core or any installed plugin. Make sure to hook this function to the init action for it to work properly:

add_action('init', function() {
    unregister_block_pattern('core/two-buttons');
});

By leveraging these methods, you can streamline your block editor’s interface and focus on the patterns that matter most for your theme or project.

Leave a Reply

Your email address will not be published. Required fields are marked *