This tutorial will show you how to easily embed WordPress.tv videos into your standalone WordPress installation using the WordPress.com shortcode format usually only available to WordPress.com site owners.
To achieve this we will be creating a shortcode and function that will allow us to copy the WordPress.tv video shortcode designed for WordPress.com rather than the HTML embed code that standalone WordPress users usually use.
Firstly we will want get the shortcode for a video on WordPress.tv to place in your WordPress post content. Below is an example of the shortcode from WordPress.tv taken from the video Matt Mullenweg: State of the Word 2012.
When you paste this shortcode into a standalone installation of WordPress is simply shows the shortcode as text and displays no video like the screenshot below.
To get WordPress.tv videos to show in your standalone WordPress installation you will have to copy our shortcode function below into your current WordPress themes functions.php file.
add_shortcode( 'wpvideo', 'wpshock_wptv_video_embed' ); function wpshock_wptv_video_embed( $atts ) { return '<object width="600" height="336" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://s0.videopress.com/player.swf?v=1.03" /><param name="wmode" value="direct" /><param name="seamlesstabbing" value="true" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="overstretch" value="true" /><param name="flashvars" value="guid=' . esc_attr( $atts[0] ) .'&isDynamicSeeking=true" /><embed width="600" height="336" type="application/x-shockwave-flash" src="http://s0.videopress.com/player.swf?v=1.03" wmode="direct" seamlesstabbing="true" allowfullscreen="true" allowscriptaccess="always" overstretch="true" flashvars="guid=' . esc_attr( $atts[0] ) .'&isDynamicSeeking=true" /></object>'; }
Now when you paste the WordPress.tv video shortcode intended for WordPress.com blogs into your standalone WordPress install post content it will automatically embed the WordPress.tv video into your post.
This is a much cleaner and manageable approach to embedding WordPress.tv videos in your standalone WordPress installation. As always please leave a comment if you have a question or improvements.
Leave a Reply
You must be logged in to post a comment.