Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Easily Embed Instagram in WordPress with oEmbed

Last updated on by
Elegant Themes
How to Easily Embed Instagram in WordPress with oEmbed

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: http://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.


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. Todd says:

    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.

  2. Stephen Clark says:

    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?

    • Editorial Staff says:

      Is the image being resized? If so look in your Settings > Media to see the maximum embed width.

  3. Julien Maury says:

    I’m afraid this code will be useless with WordPress 3.5 :
    https://twitter.com/jmlapam/status/264101995357540354

  4. greg says:

    It’s best practise to omit the last ?> from an all php file. :D
    Cool article!

  5. Mia says:

    Thank you WPB..your articles have been so helpful!

  6. Richard Wells says:

    Don’t want to be picky, but the closing ?> tag is missing from the code snippet.

    • Editorial Staff says:

      WordPress takes care of that by default. It should not give you any error.

      • Richard Wells says:

        Yes, it dawned on me after I posted the comment, I am feeling foolish…

        • Javier Villanueva says:

          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

  7. Konstantin Kovshenin says:

    Or you can simply wait for WordPress 3.5, which will ship with oEmbed support for SoundCloud, Instagram and SlideShare :)

    • Editorial Staff says:

      Didn’t even see that in the features for 3.5. Well for the next month or so, people can still use this.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.