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 to only enable specific WordPress Gutenberg blocks. By default, there is a lot of junk in there that my client will never use like buttons and page separators that I wanted to disable.
I am using the allowed_block_types
hook to create an include 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 enabled/disabled:
- 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
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.