sovetit

Add Instagram Embed in WordPress

Oct 21st, 2021 (edited)
882
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function sovetit_instagram_embed_provider() {
  3.     wp_embed_register_handler( 'sovetit-instagram', '#https:\/\/www.instagram.com/p/([^\/]*)#', function( $matches, $attr, $url ) {
  4.     return sprintf(
  5.         '<blockquote class="instagram-media" data-instgrm-captioned data-instgrm-permalink="%s" data-instgrm-version="12" style="background:#fff;border:0;border-radius:3px;max-width:540px;min-width:326px;padding:0;width:99.375%%;width:-webkit-calc(100%% - 2px);width:calc(100%% - 2px)">
  6.              <div style="padding:16px;"></div>
  7.         </blockquote><script async defer src="//www.instagram.com/embed.js"></script>'
  8.         , $url );
  9.     });
  10. }
  11. add_action( 'init', 'sovetit_instagram_embed_provider' );
RAW Paste Data