0

I am trying to make an Instagram-box on the author profile of my page. I need every profile to be different, and to do that I need to change the ID in my Instagram Widget-shortcode on every page. The shortcode for the widget is:

[instagram-feed id="" imageres="full" showheader="true" showbutton="true" buttoncolor="#fff" buttontextcolor="#000" showfollow="false"]

To change the id on every page I have used the_author_meta('instagram');. The idea was to do this:

echo do shortcode( '[instagram-feed id="<?php the_author_meta('user_email') ?>" imageres="full"  showheader="true" showbutton="true" buttoncolor="#fff" buttontextcolor="#000" showfollow="false"]');

But it wont generate because it's PHP inside a shortcode. I have also tried this:

    echo ( '[instagram-feed id="' ); 
    the_author_meta('instagram');
    echo ( '" imageres="full" showheader="true" showbutton="true" buttoncolor="#fff" buttontextcolor="#000" showfollow="false"]' ); 

which generated the code correctly with a different ID on every profile:

[instagram-feed id="1427468000 (and something different on other profile)" imageres="full" showheader="true" showbutton="true" buttoncolor="#fff" buttontextcolor="#000" showfollow="false"]

But now it will now only display as text, not be the result of the code. Anyone know how I can make this work?

  • 3
    What if you concatenate the string, like $author_ig = '[instagram-feed id="' . get_the_author_meta('instagram') . '" imageres="full" showheader="true" showbutton="true" buttoncolor="#fff" buttontextcolor="#000" showfollow="false"]'; echo do_shortcode($author_ig); – czerspalace Jan 21 '15 at 22:19
  • The above comment will do the trick. You must use do_shortcode() if you're inserting the shortcode in the template rather than in an editor. – jetlej Jan 22 '15 at 1:38
  • @czerspalace Can you add your comment as answer? Thanks! – Nicolai Apr 30 '15 at 15:25
  • @ialocin yes, will do! – czerspalace Apr 30 '15 at 17:27
  • Perfect, now Luca can accept it. @czerspalace – Nicolai Apr 30 '15 at 17:32
1

What if you concatenate the string, like

$author_ig = '[instagram-feed id="' . get_the_author_meta('instagram') . '"  imageres="full" showheader="true" showbutton="true" buttoncolor="#fff" buttontextcolor="#000" showfollow="false"]';    
echo do_shortcode($author_ig); 

I used get_the_author_meta instead of the_author_meta, because the former returns the meta as a string while the latter echo's the meta.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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