Stream Your YouTube Channel On A Page Inside Your WordPress Website

WordPress shortcodes are great. They let you perform complex operations or display dynamic content with just a tiny bit of text in any page or post.

I recently needed a way to embed the most recent videos from a Youtube channel (very dynamic information) in a WordPress page, so I decided to write a shortcode for it.

[divider /]

The code is actually pretty simple. Just add the following to your theme’s functions.php file:

COPY CODE BELOW

function youtube_feed_shortcode($atts)
{
// Defaults:
extract(shortcode_atts(array(
'user' => 'mrinternettips', // youtube user
'limit' => 5, // maximum number of videos
'height' => 385, // video height
'width' => 480 // video width
), $atts));
$data = @json_decode(file_get_contents('http://gdata.youtube.com/feeds/api/users/'.$user.'/uploads?alt=json'), TRUE);
$counter = 0;
$content = '
'; foreach($data['feed']['entry'] as $vid) { $url = $vid['media$group']['media$content'][0]['url']; $title = $vid['title']['$t']; $ycontent = $vid['content']['$t']; $content.= ''.''.''.''.''. '
'.$title.'
'. '
'.$ycontent.'
'."n"; $counter++; if($counter == $limit) { break; } } $content .= '
'; return $content; } add_shortcode('youtubefeed', 'youtube_feed_shortcode');

The shortcode below is completely configurable.

[youtubefeed user="YourChannel Name Here" limit="3" height="385" width="560"]

You can change any option as needed.

You might have noticed the code gives each element a particular class to make it CSS friendly. All you have to do is add CSS rules for three classes: .youtubefeed, .youtubetitle, and .youtubecontent.

[divider /]

My stylesheet looks like this: (this will be your style.css file)

COPY CODE BELOW

.youtubefeed {
margin: 10px;
text-align: center;
}
.youtubetitle {
font-size: 1.6em;
font-weight: bold;
margin: 3px;
}
.youtubecontent {
margin-bottom: 30px;
text-align: left;
}

Other Plugin That Will Do This:

TubePress

TubeMatic

Previous Floating Share Plugin for Wordpress
Next Top 10 FREE Wordpress Plug-ins That Are A Must To Have

About author

Jarrett Gucci
Jarrett Gucci 289 posts

Jarrett Gucci is the owner of Dynasty Web Solutions. A full service Internet presence provider specializing in WordPress development for business owners. Jarrett Gucci along with his team of professionals have designed over 400 WordPress websites. Jarrett Gucci believes strongly in creating websites that are unique, functional and generate referrals.

You might also like

WordPress Resources 0 Comments

WordPress Websites Are Better Than All Others

WordPress based websites are faster to setup, easier to maintain, easier to market and extend. About 2 years ago I started messing around with WordPress and have been deploying WordPress

WordPress Resources 0 Comments

10 Basic Tips for Improving Your WordPress Website

A lot of people use WordPress as their blogging platform. After installing WordPress, newly christened WordPress users will usually try to find and download WordPress themes that they can use

WordPress Themes 0 Comments

Top 10 FREE Coming Soon WordPress Themes

If you are planning to create an application, or any other website you should really consider having a coming soon page. On that spash page, you should have an email

WordPress Resources 0 Comments

Advantages & Disavantages of Using WordPress

There are three main advantages to hosting your own blog. You own it Can be optimized better Can add other items to improve your process There are also a couple

WordPress Resources 0 Comments

18 Tricks To Speed Up WordPress Website or Blog

WordPress is a good CMS solution and even better blogging platform, but most sites using WordPress are not maximizing its potential. Performance is one of the important factor of a

WordPress Resources 0 Comments

How to secure your WordPress blog

Repel attackers with these tips on creating a secure installation By Karl Hodge A freebie WordPress.com blog won’t cut it – get your own web space, and install the full

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply