Monday, February 6, 2012

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

Comments

2 Responses to “Adding a Featured Video Section to a Wordpress Homepage”
  1. chuqingww says:

    This is a good posting, I was wondering if I could use this write-up on my website, I will link it back to your website though. If this is a problem please let me know and I will take it down right away

  2. Kushel says:

    Sure no problem.

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!

Communicate Through Technology is Digg proof thanks to caching by WP Super Cache!

Communicate Through Technology is Digg proof thanks to caching by WP Super Cache!