Skip to content

Instantly share code, notes, and snippets.

@joemcgill
Created July 20, 2020 19:06
Show Gist options
  • Save joemcgill/765c9ed02185c11f7c957bd3ef8bd0ae to your computer and use it in GitHub Desktop.
Save joemcgill/765c9ed02185c11f7c957bd3ef8bd0ae to your computer and use it in GitHub Desktop.
Fix Instagram embeds with Jetpack shortcodes module
<?php
// Disable Jetpack's instagram shortcode since it breaks oEmbed functionality.
add_filter( 'jetpack_shortcodes_to_include', function ( $shortcodes ) {
unset( $shortcodes['instagram'] );
return $shortcodes;
}, 99 );
// Add a simple shortcode wrapper for the embed functionality to support the shortcode format.
add_shortcode( 'instagram', function ( $atts ) {
global $wp_embed;
if ( empty( $atts['url'] ) ) {
return '';
}
return $wp_embed->shortcode( $atts, $atts['url'] );
} );
@joemcgill
Copy link
Author

This is a quick workaround for this Jetpack bug which breaks the Instagram block in WordPress. Automattic/jetpack#9331

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment