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 Themes 0 Comments

Top 10 Responsive WordPress Themes

ContentsAlyeska ResponsiveModernizeSideways Portfolio WebsiteWhite LabelSuper SkeletonReactionLocusAngularAwarePropulsion A responsive design means a layout that responds well to different screen sizes. Such as iPad, tablets, Smart Phones and Desktop.  Responsive WordPress Themes

WordPress Resources 0 Comments

WordPress Setup in Less Than 10 Minutes for Less Than $10

ContentsStep #1 Step #2Step #3Have Fun With Your New WORDPRESS Website or Blog! I get asked constantly how to go about setting up WordPress.org.  I thought it would be nice

WordPress Themes 0 Comments

Building a WordPress E-Commerce Website The Right Way

Contents1. E-Commerce Ready Theme ($30 – $70)Splashing PixelsStorefront Themes2. E-Commerce WordPress Plugin  (FREE)WP e-Commerce Plugin3. Payment Processor WordPress Plugin ($40)Gold Cart Plugin4. Affiliate WordPress Plugin ($47)Affiliate Plugin5. Members Only WordPress

WordPress Resources 0 Comments

18 Tricks To Speed Up WordPress Website or Blog

Contents1. Cache Complete Generated Pages2. Disable Hotlinking and Prevent Leeching3. Choose a Good Web Host4. Split Long Posts in Several Pages5. Use Excerpts and Limit the Count of Posts Displayed

WordPress Resources 0 Comments

How To Get One Of Those Custom Images For Your Blog Comments – Gravatar / Avatar

Step 1: Visit http://en.gravatar.com and click on “Get your Gravatar today” [divider /] Step 2: Enter the email address that you use when commenting on Blogs.  You can also add

WordPress Resources 0 Comments

Best Social Popup WordPress Plugins

This is my list of Best Social Popup WordPress PluginsWordPress Popup Plugins can be extremely useful for building your social audience, growing your email list or just simply gaining more

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.