Removing Default Gutenberg Blocks, But Keeping Reusable Block Functionality?

I have been follow a tutorial here: https://rudrastyh.com/gutenberg/remove-default-blocks.html Where it discusses how to remove default Gutenberg blocks like so:

add_filter( ‘allowed_block_types’, ‘misha_allowed_block_types’, 10, 2 );

function misha_allowed_block_types( $allowed_blocks, $post ) {

$allowed_blocks = array(
‘core/image’,
‘core/paragraph’,
‘core/heading’,
‘core/list’
);

if( $post->post_type === ‘page’ ) {
$allowed_blocks[] = ‘core/shortcode’;
}

return $allowed_blocks;

}

So what this is doing is limiting the default Gutenberg blocks to image, paragraph, heading, and list. I then set the page post type to also allow for the shortcode block. So this works fine, but I am now having an issue where it removes the functionality of reusable blocks and I can’t figure out what needs to be added to add that functionality back.

I tried commenting on that article, but the author wasn’t able to think of a solution currently. I was wondering if anyone had any ideas on adding the reusable block functionality back after adding the above code snippet?

Read more here:: Removing Default Gutenberg Blocks, But Keeping Reusable Block Functionality?

Leave a Reply

Your email address will not be published. Required fields are marked *