Block Editor PHP Intermediate

Remove Embed Variations You Don’t Use

Clean up the inserter by removing embed blocks for services you never use, such as Tumblr, Reddit or Crowdsignal.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 13 lines
add_action( 'enqueue_block_editor_assets', function (): void {
	wp_add_inline_script(
		'wp-blocks',
		"wp.domReady( function () {
			var keep = [ 'youtube', 'vimeo', 'twitter', 'spotify' ];
			wp.blocks.getBlockVariations( 'core/embed' ).forEach( function ( variation ) {
				if ( keep.indexOf( variation.name ) === -1 ) {
					wp.blocks.unregisterBlockVariation( 'core/embed', variation.name );
				}
			} );
		} );"
	);
} );

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.

The inserter lists more than 30 embed blocks: Amazon Kindle, Crowdsignal, Tumblr, TED and many more. Most sites use two or three. This snippet keeps only the ones you list.

How it works

Each embed service is a variation of the core/embed block. When the editor is ready, the script loops over every variation and removes the ones not in your keep list with wp.blocks.unregisterBlockVariation().

The generic Embed block stays, so pasting any supported URL still works.

Things to watch

  • Variation names are lowercase service names such as youtube, vimeo, twitter and wordpress.
  • Existing embeds keep working; only the inserter changes.

How to test it

Search the inserter for “embed”. Only your kept services should be listed.

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