A WordPress-centric search engine for devs and theme authors



get_block_categories ›

Since5.0.0
Deprecatedn/a
get_block_categories ( $post )
Parameters:
  • (WP_Post) $post Post object.
    Required: Yes
Returns:
  • (array[]) Array of block categories.
Defined at:
Codex:

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



Source

function get_block_categories( $post ) {
	$default_categories = array(
		array(
			'slug'  => 'text',
			'title' => _x( 'Text', 'block category' ),
			'icon'  => null,
		),
		array(
			'slug'  => 'media',
			'title' => _x( 'Media', 'block category' ),
			'icon'  => null,
		),
		array(
			'slug'  => 'design',
			'title' => _x( 'Design', 'block category' ),
			'icon'  => null,
		),
		array(
			'slug'  => 'widgets',
			'title' => _x( 'Widgets', 'block category' ),
			'icon'  => null,
		),
		array(
			'slug'  => 'embed',
			'title' => _x( 'Embeds', 'block category' ),
			'icon'  => null,
		),
		array(
			'slug'  => 'reusable',
			'title' => _x( 'Reusable Blocks', 'block category' ),
			'icon'  => null,
		),
	);

	/**
	 * Filters the default array of block categories.
	 *
	 * @since 5.0.0
	 *
	 * @param array[] $default_categories Array of block categories.
	 * @param WP_Post $post               Post being loaded.
	 */
	return apply_filters( 'block_categories', $default_categories, $post );
}