Skip to content

Instantly share code, notes, and snippets.

@joemcgill
Created Jul 20, 2020
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@joemcgill joemcgill commented Jul 20, 2020

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