# Disable the Theme's Block Patterns

> Removes the patterns bundled with your active theme from the inserter, for sites that only want their own patterns.

- Type: PHP
- Runs: Run everywhere
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: patterns, themes, editor
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/disable-theme-block-patterns/

## Code

```php
add_action( 'init', function () {
    $registry = WP_Block_Patterns_Registry::get_instance();
    $prefixes = array_unique( array( get_stylesheet() . '/', get_template() . '/' ) );

    foreach ( $registry->get_all_registered() as $pattern ) {
        foreach ( $prefixes as $prefix ) {
            if ( 0 === strpos( $pattern['name'], $prefix ) ) {
                unregister_block_pattern( $pattern['name'] );
                break;
            }
        }
    }
}, 99 );
```

## Notes

Patterns from WordPress core and plugins are not affected. Use Disable Core Block Patterns for those.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Disable the Theme's Block Patterns" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
