Saturday, September 4, 2010

Adding a Featured Video Section to a Wordpress Homepage

September 26, 2009 by Kushel  
Filed under Latest, Wordpress

On my homepage, you will notice I have a featured video section. To create this section I did the following:

- Install the Video Quicktags plugin by the legend that is Viper (viper007) – dont forget to make a donation ;-)

Without using this plugin, and by adding the embeding code directly, I had nothing but a ton of script errors in IE, but as always Firefox was perfect!

- Create a Featured Video category.

- Set the area on your homepage where you want your videos to be displayed, to hit posts from this category.

- Add a post.

- Within the post, create a Custom Field. Call it for example, Video_Link, and for the value, add a quicktag to the video you want to display, e.g.


[ viddler id=bc656bb0&w=280&h=166 ]

where w is the width and h is the height.

- Open home.php in the wordpress editor, and locate the area which you have set to display your featured videos.

- Comment out the following:

<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
<? php the_content_limit(80, ""); ?>

- Add replace with:

// If post contains a vid_link custom field
<?php $vid_link = get_post_meta($post->ID, 'Video_Link', $single = true);
if($vid_link !== '') {
// first display the title
?>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
<?php
       // Get the contents of the value of the custom field and apply Quicktag filter
$vid_link = apply_filters('the_content', $vid_link);
      // display video
echo $vid_link;
}
?>

You might notice that if you have other plugins installed, such as TweetMe or Share/Save buttons, unless you have unchecked the ‘display on home page’ checkbox on the plugin settings, this will also be displayed with the video (from the apply_filters command), so I would recommend checking this option to hide them in the home page.

  • Twitter
  • Facebook
  • Delicious
  • Bebo
  • StumbleUpon
  • Digg
  • Blogger Post
  • WordPress
  • Share/Bookmark

Related posts:

  1. Getting started with Wordpress and SEO, Video by Matt Cutts and Wordcamp 2009
  2. Wordpress on IIS Cannot Handle 404 File Not Found

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!