How to disable specific shortcodes in Jetpack

Jetpack includes many shortcodes allowing you to embed videos, audio files, images, and other media into your posts.

If you want to deactivate a specific shortcode without deactivating the Shortcodes module, you can add the following code to a functionality plugin. Please note that this will not work in a theme’s functions.php file due to the order in which WordPress loads plugins and themes and how we’re loading the shortcodes list.

function my_remove_shortcode_function( $shortcodes ) {
	$jetpack_shortcodes_dir = WP_CONTENT_DIR . '/plugins/jetpack/modules/shortcodes/';

	$shortcodes_to_unload = array( 'ted.php', 'soundcloud.php', );

	foreach ( $shortcodes_to_unload as $shortcode ) {
		if ( $key = array_search( $jetpack_shortcodes_dir . $shortcode, $shortcodes ) ) {
			unset( $shortcodes[$key] );
		}
	}

	return $shortcodes;
}
add_filter( 'jetpack_shortcodes_to_include', 'my_remove_shortcode_function' );

In the code above, you’ll need to add to or remove shortcodes from the $shortcodes_to_unload array. It requires the file name of the shortcode you want to deactivate.

This entry was posted in Code snippets, Tips & Tricks and tagged . Bookmark the permalink.

Explore the benefits of Jetpack plans

Compare plans in detail to see how Jetpack can help you design, market, and secure your WordPress site.

Compare plans

Have a question about this article?

Comments are currently closed for this article, but rest assured we're still here to help! Send us a message and we'll get back to you.

Contact us
  • Enter your email address to follow this blog and receive news and updates from Jetpack!

    Join 103,528 other followers

  • Our most popular posts

  • Browse by topic

  • %d bloggers like this: