Skip to content

Instantly share code, notes, and snippets.

@smonteverdi
Created July 24, 2012 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smonteverdi/3172755 to your computer and use it in GitHub Desktop.
Save smonteverdi/3172755 to your computer and use it in GitHub Desktop.
WordPress: Embed YouTube vid with custom field
Make a custom field in post first.... ex. video_url
// Get the video URL and put it in the $video variable
$video = get_post_meta($post->ID, 'video_url', true);
// Echo the embed code via oEmbed
echo wp_oembed_get( $video, array( 'width' => 218, 'height' => 127 ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment