Block Editor PHP Intermediate

Remove Built-In Block Styles

Remove style options you don't want editors to use, such as the Rounded image style or the Plain quote style.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 10 lines
add_action( 'enqueue_block_editor_assets', function (): void {
	wp_add_inline_script(
		'wp-blocks',
		"wp.domReady( function () {
			wp.blocks.unregisterBlockStyle( 'core/image', 'rounded' );
			wp.blocks.unregisterBlockStyle( 'core/quote', 'plain' );
			wp.blocks.unregisterBlockStyle( 'core/separator', 'dots' );
		} );"
	);
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

Core blocks come with style variations, like a rounded image or a dots separator. If they don’t fit your design, editors shouldn’t be able to pick them. This snippet removes them from the editor.

How it works

Core block styles are registered in JavaScript, so they have to be removed in JavaScript too. The snippet adds a small script after the blocks package loads, and when the editor is ready, wp.blocks.unregisterBlockStyle() removes each one by block name and style name.

Things to watch

  • Blocks already using a removed style keep its class until they’re edited, and your theme may still style them.
  • To find style names, select a block and inspect the Styles buttons, or check the block’s documentation.

How to test it

Add an Image block and open Styles. “Rounded” should be gone.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only