Title: Using shortcode and variable
Last modified: August 21, 2016

---

# Using shortcode and variable

 *  Resolved [jayseventwo](https://wordpress.org/support/users/jayseventwo/)
 * (@jayseventwo)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/using-shortcode-and-variable/)
 * Hi guys – great plugin!
 * I have used the do_shortcode syntax to display YouTube videos from within my 
   theme, which successfully works, but i now want to use a variable for the video_id,
   but cannot seem to get it to work.
 *     ```
       $youtube_id = the_field('new_youtube_link');
       	echo do_shortcode('[video_lightbox_youtube width="1280" height="720" auto_thumb="1" video_id="'.$youtube_id.'"]');
       ```
   
 * This just echo’s out the ID, with a message “Error! You must specify a value 
   for the Video ID, Width, Height parameters to use this shortcode!”
 * Any ideas?
 * Thanks in advance.
 * [https://wordpress.org/plugins/wp-video-lightbox/](https://wordpress.org/plugins/wp-video-lightbox/)

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

 *  Thread Starter [jayseventwo](https://wordpress.org/support/users/jayseventwo/)
 * (@jayseventwo)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/using-shortcode-and-variable/#post-4863434)
 * I should just add that i am inserting the video id through a custom field called“
   new_youtube_link”
 *  Thread Starter [jayseventwo](https://wordpress.org/support/users/jayseventwo/)
 * (@jayseventwo)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/using-shortcode-and-variable/#post-4863559)
 * Okay, so simple mistake – should have used “get_field” instead of “the_field”–
   all fixed now.
 * FYI: i was using the advanced custom fields plugin to create the custom field,
   for anyone wondering.

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

The topic ‘Using shortcode and variable’ is closed to new replies.

 * ![](https://ps.w.org/wp-video-lightbox/assets/icon-128x128.png?rev=981252)
 * [WP Video Lightbox](https://wordpress.org/plugins/wp-video-lightbox/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-video-lightbox/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-video-lightbox/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-video-lightbox/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-video-lightbox/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-video-lightbox/reviews/)

## Tags

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

 * 2 replies
 * 1 participant
 * Last reply from: [jayseventwo](https://wordpress.org/support/users/jayseventwo/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/using-shortcode-and-variable/#post-4863559)
 * Status: resolved