Believe it or not, finding this information in the official WordPress documentation was a nightmare. I had to go through the WordPress codebase itself to find these values.
In a site I am working on, I wanted only to enable specific WordPress Gutenberg blocks. By default, my client will never use a lot of junk, like buttons and page separators that I wanted to disable.
I am using the allowed_block_types
hook to create an inclusion list where I specify what blocks I want to enable. You can also add your custom blocks to this list.
add_filter( 'allowed_block_types', 'theme_allowed_block_types', 10, 2 ); /** * Set allowed block types on pages/posts/CPTs */ function theme_allowed_block_types( $allowed_blocks, $post ) { if ( ! ( $post instanceof WP_Block_Editor_Context ) ) { return $allowed_blocks; } $allowed_blocks = array( 'core/freeform', 'core/video', 'core/heading', 'core/image', 'core/gallery', 'core/embed', 'core/table', 'core/list', 'core/paragraph', 'core/pullquote', 'core/html' ); return $allowed_blocks; }
A fair warning. If you’re not using WordPress 5.8 or above, the above might cause issues for you.
Here is a list of core Gutenberg block types that can be specified:
- core/paragraph
- core/image
- core/heading
- core/gallery
- core/list
- core/quote
- core/shortcode
- core/archives
- core/audio
- core/button
- core/buttons
- core/calendar
- core/categories
- core/code
- core/columns
- core/column
- core/cover
- core/embed
- core/file
- core/group
- core/freeform
- core/html
- core/media-text
- core/latest-comments
- core/latest-posts
- core/missing
- core/more
- core/nextpage
- core/preformatted
- core/pullquote
- core/rss
- core/search
- core/separator
- core/block
- core/social-links
- core/social-link
- core/spacer
- core/subhead
- core/table
- core/tag-cloud
- core/text-columns
- core/verse
- core/video
Thank you from the bottom of my geeky heart! You saved me loads of time. I even tweeted about this!!
This has been super handy, but for some reason it’s not working for core/group or core/spacer (they remain hidden, even when I put them in the allowed blocks list). Any idea why that might be?
I don’t understand why the WP documentation is so opaque. Thanks for providing the list of core blocks 😅
Useful list. Question: How can i allow only Youtube and Vimeo?
Legend! You’ve saved me loads of time.
Official docs may have improved since this was written, https://developer.wordpress.org/block-editor/reference-guides/core-blocks/. This page has the “name” needed for templates, plus some other details.