# Your Own Block Category at the Top of the Inserter

> Adds a block category named after your site to the top of the block inserter and moves custom blocks with a chosen namespace into it, so editors find your bespoke blocks first.

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

## Code

```php
// Block name prefixes that belong in the category.
$wpide_block_namespaces = array( 'wpide/' );

add_filter( 'block_categories_all', function ( $categories ) {
    array_unshift( $categories, array(
        'slug'  => 'site-blocks',
        'title' => get_bloginfo( 'name' ),
        'icon'  => null,
    ) );
    return $categories;
} );

add_filter( 'register_block_type_args', function ( $args, $name ) use ( $wpide_block_namespaces ) {
    foreach ( $wpide_block_namespaces as $prefix ) {
        if ( 0 === strpos( $name, $prefix ) ) {
            $args['category'] = 'site-blocks';
        }
    }
    return $args;
}, 10, 2 );
```

## Notes

Set $wpide_block_namespaces to the prefix of your blocks, such as acme/ or wpide/.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Your Own Block Category at the Top of the Inserter" 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/
