With the following code, you can filter and return a small selection of core blocks that you want to use in your theme. Some of the default blocks might not be suitable for your theme or perhaps you want to replace all the native ones your own custom blocks and make it really clear which blocks to choose from.

The second parameter $editor_context is an object of the type WP_Block_Editor_Context which contains information about the block editor that is being rendered. These can be one of:

  • core/edit-post – The post editor at /wp-admin/edit.php.
  • core/edit-widgets – The widgets editor at /wp-admin/widgets.php.
  • core/customize-widgets – The widgets editor at /wp-admin/customize.php.
  • core/edit-site – The site editor at /wp-admin/site-editor.php.

Reference: https://developer.wordpress.org/reference/classes/wp_block_editor_context/

The function first checks that the Editor context post object exists and if so, assumes we’re in the core/edit-post context. Once true the selected array of blocks will be returned. Alternatively you could just return a full array of the block types you want without doing a check.

function webassembler_allowed_block_types( $allowed_block_types, $editor_context ) {
	if ( ! empty( $editor_context->post ) ) {
		return array(

	return $allowed_block_types;
add_filter( 'allowed_block_types_all', 'webassembler_allowed_block_types', 10, 2 );
Back to blog