In the past we have shown you how to embed videos, slideshare, and soundcloud in WordPress using oEmbed. One of our users asked if there was a way to easily embed Instagram in WordPress with oEmbed. The answer is YES. In this article, we will show you how to add instagram oEmbed support in WordPress.
Update: You DO NOT have to use this tutorial anymore. WordPress 3.5+ has built-in oEmbed support for Instagram.
All you have to do is open a blank .php file and call it wpb-instagram.php. Then copy the code below and save it in there. Upload the file into your plugins folder, and simply activate the plugin.
<?php /* Plugin Name: WPB Add Instagram oEmbed Description: Adds oEmbed support for Instagram Author: Syed Balkhi Author URI: https://www.wpbeginner.com */ // Add Instagram oEmbed function wpb_oembed_instagram(){ wp_oembed_add_provider( 'http://instagr.am/*/*', 'http://api.instagram.com/oembed' ); wp_oembed_add_provider( 'http://www.instagram.com/*/*', 'http://api.instagram.com/oembed' ); } add_action('init','wpb_oembed_instagram');
Now all you have to do is paste the instagram image URL in your WordPress post on its own line. It will automatically embed the image, and boom. That’s how easy it is.
I have added an Instagram video on wordpress with the oAuth but am experiencing a problem. I have the page broken into 2 columns with videos going down the page and the Instagram videos have a large white space under them. Do you know a way to fix that? Here is my site http://www.BeardGrowl.com
Thanks for any help you might be able to offer.
I implemented this neat snippet as you instructed however when it rendered on my WP blog/site, it was a thumbnail sized photo. Is that the intended behavior? Or is it supposed to render the image at full size, meaning there is something in my code I need to dig into?
Is the image being resized? If so look in your Settings > Media to see the maximum embed width.
I’m afraid this code will be useless with WordPress 3.5 :
https://twitter.com/jmlapam/status/264101995357540354
Sorry : the link is here : http://core.trac.wordpress.org/changeset/22351
It’s best practise to omit the last ?> from an all php file.
Cool article!
Thank you WPB..your articles have been so helpful!
Thanks for the kind words Mia
Don’t want to be picky, but the closing ?> tag is missing from the code snippet.
WordPress takes care of that by default. It should not give you any error.
Yes, it dawned on me after I posted the comment, I am feeling foolish…
WP doesn’t add a closing ?> tag, it’s just not needed in php files and overall a best practice to just omit it to prevent sending extra whitespace by accident
Or you can simply wait for WordPress 3.5, which will ship with oEmbed support for SoundCloud, Instagram and SlideShare
Didn’t even see that in the features for 3.5. Well for the next month or so, people can still use this.