Skip to content

Instantly share code, notes, and snippets.

@wookiecooking
Created May 14, 2013 03:34
Show Gist options
  • Save wookiecooking/5573472 to your computer and use it in GitHub Desktop.
Save wookiecooking/5573472 to your computer and use it in GitHub Desktop.
[WordPress] Embed YouTube videos using the shortcode [yt]
<?php
/*
Plugin Name: Youtube Shorty
Description: Embed YouTube videos using the shortcode [yt]
*/
function youtube_short($atts)
{
if (!isset($atts['width'])) {$atts['width']="100%";}
if (!isset($atts['height'])) {$atts['height']="400px";}
$id = $atts['id'];
$width=$atts['width'];
$height=$atts['height'];
$videosrc = "<iframe src=\"http://www.youtube.com/embed/" . $id . "\" width= \"". $width . "\" height=\"" . $height . "frameborder=\"0\" allowfullscreen>" . "</iframe>" .
"";
return $videosrc;
}
add_shortcode("yt", "youtube_short");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment