Add YouTube channel to post

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){
		'user_name' => '',
		'show' => '',
		'width' => '',
), $atts));		

$feed = new SimplePie();
$success = $feed->init();
    $YT_PlayerPage = "".$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);?>
	<?php echo  $item->get_title();?>

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"]

Leave a Reply

Your email address will not be published. Required fields are marked *