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'm collecting Youtube video links in custom fields, but when I echo out the value it just prints the URL. How do I get WordPress to convert it to be embedded?


<?php global $post;
$video = get_post_meta( $post->ID, '_my_video_link', true );
echo ( $video ); ?>

Just outputs http://www.youtube.com/watch?v=tkEvSjdDfiA

But I want it to display the actual video...

Thanks for any advice

share|improve this question

Aha! WordPress has a built in function for it :D

<?php echo $embed_code = wp_oembed_get( $video ); ?>


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.