Jump to content

YouTube Channel Block Feed


Guitar Gathering

Recommended Posts

Hey guys,

I'd like to have a block on my forum in the side column that shows a feed from my YouTube channel - similar to a Facebook or Twitter feed.

Just a small block like the member statistics type of block that can be added to the front look of the forum.

Is there anything like this?

Thanks for any help you can offer.

 

Link to comment

Got Pages?

  • Create a custom block, with Manual PHP as the content editor type
  • Locate your channel ID
  • Add the following code to the block:
$rss = simplexml_load_file('https://www.youtube.com/feeds/videos.xml?channel_id=YOURCHANNELID');
echo '<h1>'. $rss->title . '</h1>';
foreach ($rss->entry as $item) {
	echo '<a href="'.$item->link['href'].'">'.$item->title.'</a><br>';
}
  • Save the block
  • Drag the custom block in to position

You now have the basics in place and can go from there.

Not got Pages? Use this plugin instead:

 

Link to comment

The following will give you the basics for the items you requested here (obviously, replace the channel id I'm using in the code):

$rss = simplexml_load_file('https://www.youtube.com/feeds/videos.xml?channel_id=UCoxg3Kml41wE3IPq-PC-LQw');
echo '<h1>'. $rss->title . '</h1>';
$count = 1;
foreach ($rss->entry as $item) {
	if($count <= 5) {
		$videoid = str_replace('yt:video:','',$item->id);
		echo '<a href="'.$item->link['href'].'"><img src="https://i1.ytimg.com/vi/'.$videoid.'/2.jpg"></a><br>';
		$count++;
   } else {
     break; 
   }
}
echo '<a href="http://www.youtube.com/channel/UCoxg3Kml41wE3IPq-PC-LQw?sub_confirmation=1">Subscribe<a>';

Result:

image.thumb.png.c704c1b9a1470d16e54e47b2936a6ce8.png

Link to comment
  • 4 weeks later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...