Title: block_categories
Published: December 6, 2018
Last modified: May 20, 2026

---

# apply_filters_deprecated( ‘block_categories’, array[] $block_categories, WP_Post $post )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#wp--skip-link--target)

This hook has been deprecated since 5.8.0. Use the {@see ‘block_categories_all’}
filter instead.

Filters the default array of categories for block types.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#parameters)󠁿

 `$block_categories`array[]

Array of categories for block types.

`$post`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)

Post being loaded.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#source)󠁿

    ```php
    $block_categories = apply_filters_deprecated( 'block_categories', array( $block_categories, $post ), '5.8.0', 'block_categories_all' );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/block-editor.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/block-editor.php#L100)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/block-editor.php#L100-L100)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#related)󠁿

| Used by | Description | 
| [get_block_categories()](https://developer.wordpress.org/reference/functions/get_block_categories/)`wp-includes/block-editor.php` |

Returns all the categories for block types that will be shown in the block editor.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.8.0](https://developer.wordpress.org/reference/since/5.8.0/) | Deprecated. Use the ['block_categories_all'](https://developer.wordpress.org/reference/hooks/block_categories_all/) filter instead. | 
| [5.0.0](https://developer.wordpress.org/reference/since/5.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#comment-content-3852)
 2.    [Mahdi](https://profiles.wordpress.org/mahdiyazdani/)  [  6 years ago  ](https://developer.wordpress.org/reference/hooks/block_categories/#comment-3852)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fblock_categories%2F%23comment-3852)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fblock_categories%2F%23comment-3852)
 4.  Register a new block category for “My Plugin” if it doesn’t exist already.
 5.  **Note**: _You can also pass a second argument `$post` to generate a different
     category depending on the post’s content or type._
 6.      ```php
         /**
          * Creating a new (custm) block category.
          *
          * @param   array $categories     List of block categories.
          * @return  array
          */
         function wpdocs_new_block_category( $categories ) {
             // Plugin’s block category title and slug.
             $block_category = array( 'title' => esc_html__( 'My Plugin', 'text-domain' ), 'slug' => 'myplugin' );
             $category_slugs = wp_list_pluck( $categories, 'slug' );
     
             if ( ! in_array( $block_category['slug'], $category_slugs, true ) ) {
                 $categories = array_merge(
                     $categories,
                     array(
                         array(
                             'title' => $block_category['title'], // Required
                             'slug'  => $block_category['slug'], // Required
                             'icon'  => 'wordpress', // Slug of a WordPress Dashicon or custom SVG
                         ),
                     )
                 );
             }
     
             return $categories;
         }
         add_filter( 'block_categories', 'wpdocs_new_block_category' );
         ```
     
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fblock_categories%2F%3Freplytocom%3D3852%23feedback-editor-3852)
 8.   [Skip to note 4 content](https://developer.wordpress.org/reference/hooks/block_categories/?output_format=md#comment-content-5211)
 9.    [Cory Hughart](https://profiles.wordpress.org/cr0ybot/)  [  5 years ago  ](https://developer.wordpress.org/reference/hooks/block_categories/#comment-5211)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fblock_categories%2F%23comment-5211)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fblock_categories%2F%23comment-5211)
 11. If you’ve come here because you’re getting deprecation notices about `block_categories`,
     as of 5.8 this filter is deprecated. Use `block_categories_all` instead.
 12. If you need to apply categories based on post type or other $post data, you can
     do so like this:
 13.     ```php
         /**
          * Create a custom block category for posts only.
          *
          * @param   array $categories     List of block categories.
          * @return  array
          */
         function wpdocs_post_block_category( $categories, $editor_context ) {
         	if ( $editor_context->post instanceof WP_Post && 'post' === $editor_context->post->post_type ) {
         		$categories = array_merge(
         			$categories,
         			array(
         				'title' => __( 'Title' ), // Required
         				'slug'  => 'slug', // Required
         				'icon'  => 'wordpress', // Slug of a WordPress Dashicon or custom SVG
         			)
         		);
         	}
     
         	return $categories;
         }
         add_filter( 'block_categories_all', 'wpdocs_post_block_category' );
         ```
     
 14.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fblock_categories%2F%3Freplytocom%3D5211%23feedback-editor-5211)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fblock_categories%2F)
before being able to contribute a note or feedback.