Unregisters a block style.
Parameters
$block_namestringrequired- Block type name including namespace.
$block_style_namestringrequired- Block style name.
Source
function unregister_block_style( $block_name, $block_style_name ) {
return WP_Block_Styles_Registry::get_instance()->unregister( $block_name, $block_style_name );
}
Changelog
| Version | Description |
|---|---|
| 5.3.0 | Introduced. |
The following code sample unregister the style named ‘fancy-quote’ from the core quote block:
unregister_block_style( 'core/quote', 'fancy-quote' );Important: The function
unregister_block_styleonly unregisters styles that were registered on the server usingregister_block_style. The function does not unregister a style registered using client-side code.As Marie Comet mentioned, you cannot use
unregister_block_style()on a style that was registered serverside (e.g. via PHP). The following PHP will not unregister a block style from the core/table block:You can use the Block API via JavaScript to unregister it. Running the following JavaScript will successfully unregister the style.
For more info, look under Styles in the Block API Reference of the Block Editor Handbook.
I wanted to unregister default core/quote block Plain style.
First I have tried
unregister_block_style(‘core/quote’, ‘plain’)– not working!Then I tried JS
wp.blocks.unregisterBlockStyle()– partly working! Block style was removed from editor, but was present in FSE Style guide section!…Then I came back to PHP and tried to filter block.json args:
… And it worked finally! This API seems inconsistent… (