Get Custom Field with echo do_shortcode

Craig Martindale
Bert and Dip
1 min readNov 5, 2015

--

So today I cam across this issue. I wanted to get a custom field, inside a shortcode which was in a custom template file.

Here is how to do it, it’s really quite simple. Here, my custom field is called ‘vimeo_id’, so I am going to create a variable which calls that:

<?php $vimeoid = get_post_meta($post->ID, ‘vimeo_id’, true); ?>

And then I will insert that variable into the standard do_shortcode function:

<?php echo do_shortcode( ‘[video_lightbox_vimeo5 video_id=”’.$vimeoid.’” width=”640" height=”480" anchor=”Watch Video”]’); ?>

And that’s it.

--

--