Title: Shortcode with Instagram embedding
Last modified: March 31, 2020

---

# Shortcode with Instagram embedding

 *  Resolved [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shortcode-with-instagram-embedding/)
 * Hi,
 * I know I can display Instagram photos in my posts by simply copy-pasting the 
   url of an image, for example [https://www.instagram.com/p/Bqj5sIEgDv2/](https://www.instagram.com/p/Bqj5sIEgDv2/)
 * Now, I have a shortcode that I would like to be able to output Instagram urls
   like the one above.
 * If I just return “[https://www.instagram.com/p/Bqj5sIEgDv2/&#8221](https://www.instagram.com/p/Bqj5sIEgDv2/&#8221);,
   WP simply outputs this as a text string in the post.
 * I have also tried to wrap the Instagram url in do_shortcode() but that didn’t
   work too.
 * Anyone know a secret trick for making a shortcode output an Instagram url so 
   the post displays the image?
 * Thanks,
    Mads
    -  This topic was modified 6 years, 2 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
      Reason: Moved to Fixing WordPress, this is not an Developing with WordPress
      topic

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shortcode-with-instagram-embedding/#post-12603506)
 * Try running the URL through wp_oembed_get() within your shortcode handler and
   return _that_ returned HTML string.
 *  Thread Starter [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * (@madsphi)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/shortcode-with-instagram-embedding/#post-12604680)
 * Thanks! wp_oembed_get() works.
 * Only issue is that it slows things down vs. having the Instagram url directly
   in the post content.
 * Luckily I found this cache trick by Stanislav Khromov that fixes the performance
   issue: [https://snippets.khromov.se/how-to-cache-the-wp_oembed_get-function/](https://snippets.khromov.se/how-to-cache-the-wp_oembed_get-function/)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Shortcode with Instagram embedding’ is closed to new replies.

## Tags

 * [embedding](https://wordpress.org/support/topic-tag/embedding/)
 * [instagram](https://wordpress.org/support/topic-tag/instagram/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Mads Phikamphon](https://wordpress.org/support/users/madsphi/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/shortcode-with-instagram-embedding/#post-12604680)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
