I'm trying to unregister core block types in WordPress Gutenberg.
I've used the code provided here: https://github.com/WordPress/gutenberg/blob/master/docs/extensibility/extending-blocks.md#removing-blocks
But I can't get it to work. I feel like there may be a simple step I am missing?
- I created a plugin which I activated in my WP theme.
- In my plugin [clore-blocks] folder I created "clore-blocks.php". It contains:
/** * Remove certain blocks. */ function clore_blacklist_blocks() { wp_enqueue_script( 'clore-blacklist-blocks', plugins_url( 'blocks.js', __FILE__ ), array( 'wp-blocks' ), filemtime( plugin_dir_path( __FILE__ ) . 'blocks.js' ) // Version: filemtime - Gets file modification time. ); } add_action( 'enqueue_block_editor_assets', 'clore_blacklist_blocks' );
- In blocks.js I have only:
wp.blocks.unregisterBlockType( 'core/verse' );
I thought this would remove the "Verse" block type from being used, but when I go to edit a page with the Gutenberg editor, "Verse" is still there.
When I view the page source from the WP edit page, I can see that my "blocks.js" file is being referenced correctly, but It's just not doing anything... or at least not what I want it to do. Do you have any idea why that is?
wp.blocks.unregisterBlockType( 'core/verse' )
(or any other core block type) I get an error in the console that this block type is not registered.