Title: Shortcode and varaible
Last modified: August 21, 2016

---

# Shortcode and varaible

 *  Resolved [yoderman94](https://wordpress.org/support/users/yoderman94/)
 * (@yoderman94)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/shortcode-and-varaible/)
 * I need some help, this may be a noob question, I am trying to add a string variable
   into my short code. Here is what I have so far:
 *     ```
       $instagram_title = get_post_meta(get_the_ID(), 'instagram_title', true);
       if(isset($instagram_title) && $instagram_title != "") :
           echo do_shortcode("[easy-instagram limit=2 caption_hashtags=false caption_char_limit=0 author_text='' thumb_click='thickbox' time_text='' thumb_size=220px tag='" .$instagram_title. "']");
       endif;
       ```
   
 * My ultimate goal is to utilize the “$instagram_title” so that I don’t have to
   create a ton of widgets for each page in the site.
 * [http://wordpress.org/plugins/easy-instagram/](http://wordpress.org/plugins/easy-instagram/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [yoderman94](https://wordpress.org/support/users/yoderman94/)
 * (@yoderman94)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/shortcode-and-varaible/#post-4560811)
 * For anyone that comes across this in the future, here is what I figured out:
 *     ```
       $askavl_instagram_contact_title = get_post_meta(get_the_ID(), 'askavl_instagram_contact_title', true);
           if(isset($askavl_instagram_contact_title) && $askavl_instagram_contact_title != "") :
               $tag = str_replace("#","", ((string)$askavl_instagram_contact_title) );
       	    $thumbsize = "220px";
       	    $image_limit = "2";
       	    $easyInstagramSC = "[easy-instagram limit={$image_limit} caption_hashtags=false caption_char_limit=0 author_text='' thumb_click='thickbox' time_text='' thumb_size={$thumbsize} tag='{$tag}']";
       		echo do_shortcode( $easyInstagramSC );
       ```
   
 * From what I can tell my error was in the concatenation. This is working, hoewever
   if someone knows a better solution I would like to improve this.

Viewing 1 replies (of 1 total)

The topic ‘Shortcode and varaible’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/easy-instagram_675054.svg)
 * [Easy Instagram](https://wordpress.org/plugins/easy-instagram/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/easy-instagram/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/easy-instagram/)
 * [Active Topics](https://wordpress.org/support/plugin/easy-instagram/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/easy-instagram/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/easy-instagram/reviews/)

## Tags

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

 * 1 reply
 * 1 participant
 * Last reply from: [yoderman94](https://wordpress.org/support/users/yoderman94/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/shortcode-and-varaible/#post-4560811)
 * Status: resolved