Allowed blocks list for WordPress Gutenberg editor

Using this handy function on the allowed_block_types_all (Codex) hook, you can create an “allow list” of Gutenberg block editor blocks to disable default or plugin blocks that you don’t want or need. I don’t expect this will have much if any of a performance benefit, but it is helpful for reducing editor clutter.

Rather than deleting the array items you don’t want, I recommend that you simply comment them out by prepending the line with a // so you can easily reenable them later if needed.

This code can go in your functions.php file or a custom plugin.

/* 
	Set allowed block types to remove some unhelpful defaults
	https://addy.codes/snippets/allowed-blocks-list-for-wordpress-gutenberg-editor/
*/
function addycodes_allowed_block_types($allowed_blocks) { 
	return array(
		'core/archives',
		'core/audio',
		'core/button',
		'core/buttons',
		'core/categories',
		'core/code',
		'core/column',
		'core/columns',
		'core/coverImage',
		'core/embed',
		'core/file',
		'core/group',
		'core/freeform',
		'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/page-list',
		'core/preformatted',
		'core/pullquote',
		'core/rss',
		'core/search',
		'core/separator',
		'core/block',
		'core/social-links',
		'core/social-link',
		'core/spacer',
		'core/table',
		'core/tag-cloud',
		'core/text-columns',
		'core/verse',
		'core/video',
		'core/site-logo',
		'core/site-tagline',
		'core/site-title',
		'core/query',
		'core/post-template',
		'core/query-title',
		'core/query-pagination',
		'core/query-pagination-next',
		'core/query-pagination-numbers',
		'core/query-pagination-previous',
		'core/post-title',
		'core/post-content',
		'core/post-date',
		'core/post-excerpt',
		'core/post-featured-image',
		'core/post-terms',
		'core/loginout'
	);
}
add_filter('allowed_block_types_all', 'addycodes_allowed_block_types');

Get a list of all available Gutenberg block editor blocks

As the block editor evolves it’s likely that the array of blocks in the sample code above will change and this post will drift out of date. You’ll probably also have some plugins that add their own blocks or even your own custom ones.

To find a list of all block names on your site, simply:

  1. Log in to your admin area and open up any post or page in the Gutenberg editor
  2. Open the developer tools panel in your browser and go to the ‘Console’ tab
  3. Paste the following code wp.blocks.getBlockTypes() in to your console and press enter to run
  4. The console should return an array of all available block names that you can use in the above snippet, you may need to expand the view to see them all

Make sure you do not already have the snippet above in place when requesting the blocks list, else you’ll only see your allowed ones.

Common plugin block names

Advanced Custom Fields (ACF)

If you’re using the ACF Advanced Custom Fields block API, your block names will be acf/block-name.

Contact Forms

Contact Form 7

The Contact Form 7 form block is contact-form-7/contact-form-selector.

Gravity Forms

The Gravity Forms form block is gravityforms/form.

Categories: