Today I am going to show you how to add a YouTube Channel to a post or page using a short code.
So open up your functions.php file and copy the follow in there. Make sure to include it between the php tags .
function youtubechannel($atts){
extract(shortcode_atts(array(
'user_name' => '',
'show' => '',
'width' => '',
), $atts));
$feed = new SimplePie();
$feed->set_feed_url("http://gdata.youtube.com/feeds/api/users/".$user_name."/uploads");
$feed->enable_cache(false);
$feed->set_timeout(5);
$success = $feed->init();
$feed->handle_content_type();
$YT_PlayerPage = "http://www.youtube.com/user/".$user_name."#play/uploads/";
$YT_VideoNumber = 0;
$ShowMax = $show-1;
foreach ($feed->get_items() as $item)
{
if ($enclosure = $item->get_enclosure())
{
$YT_VideoID = substr(strstr($item->get_permalink(), 'v='), 2, 11);?>
Once thats done, save the file and log into your admin area.
Install wp-prettyPhoto.
This is to add a nice module window to play the video in.
So we are all set now
So open a post or page and simply copy the following in there where you want you videos to show.
[channel user_name="channel name" show="number of videos" width="size"]
The "user_name" defines which channel to pull, the "show" defines the number of videos to show and "width" sets the size of the thumbnails.
the demo at the top is using
[channel user_name="radiohead" show="4" width="85"]
[channel user_name="radiohead" show="4" width="85"]