Skip to content

Instantly share code, notes, and snippets.

@RupGautam
Last active June 28, 2017 01:58
Show Gist options
  • Select an option

  • Save RupGautam/1d99256acc74cc0d5e5081314fd7b4f8 to your computer and use it in GitHub Desktop.

Select an option

Save RupGautam/1d99256acc74cc0d5e5081314fd7b4f8 to your computer and use it in GitHub Desktop.
youtube id to video embed on wordpress post
// Get the video URL and put it in the $video variable
if (isset($_GET['v'])) $videoid = $_GET['v'];
// Check if there is in fact a video URL
if ($videoid) {
	echo '<div class="videoContainer">';
	// Echo the embed code via oEmbed
	echo wp_oembed_get( 'http://www.youtube.com/watch?v=' . $videoid ); 
	echo '</div>';
}
?>
/post-title?v="youtube-id"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment