WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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. "']");

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.

share|improve this question

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.