Skip to content

Instantly share code, notes, and snippets.

@hereswhatidid
Last active March 8, 2019 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hereswhatidid/16a76072b9806abb09b89a63ca12765f to your computer and use it in GitHub Desktop.
Save hereswhatidid/16a76072b9806abb09b89a63ca12765f to your computer and use it in GitHub Desktop.
Register custom Gutenberg block category
<?php
function new_category( $categories, $post ) {
return array_merge(
$categories,
array(
array(
'slug' => 'custom-category',
'title' => __( 'Custom Category', 'language' ),
),
)
);
}
add_filter( 'block_categories', 'new_category', 10, 2);
<?php
add_filter( 'allowed_block_types', 'allowed_block_types' );
function allowed_block_types( $allowed_blocks ) {
return [
'core/image',
'core/paragraph',
'core/heading'
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment