Hide Specific Blocks From the Inserter
Removes the core blocks you list from the post editor, so writers only see the blocks you want them to use.
Opens WPIDE on
Code
add_action( 'enqueue_block_editor_assets', function () {
// Block names to remove.
$blocks = array( 'core/verse', 'core/pullquote' );
wp_add_inline_script(
'wp-edit-post',
'wp.domReady(function(){' . wp_json_encode( $blocks ) . '.forEach(function(name){if(wp.blocks.getBlockType(name)){wp.blocks.unregisterBlockType(name);}});});'
);
} );
Notes
Posts that already contain a removed block will show it as unsupported in the editor.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.