Developers

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 Developers. Bookmark the permalink.
Developers

Jeremy Herve profile
Jeremy Herve

WordPress, TV Series, music, kids, and board games. I think that's probably the best way to define me in a few words. 🙂 I work at Automattic where I lead a team building tools for bloggers and creators. I talk a lot about WordPress things, but also about all things open source in general. I live in Brittany, France, so you'll also find me sharing pictures from our beautiful region from time to time.

Explore the benefits of Jetpack

Learn how Jetpack can help you protect, speed up, and grow your WordPress site. Get up to 50% off your first year.

Explore plans

Have a question?

Comments are closed for this article, but we're still here to help! Visit the support forum and we'll be happy to answer any questions.

View support forum