Embedding YouTube Videos in Wordpress

To embed YouTube videos in a wordpress blog follow these instructions:

  1. Log into the blog (as an administrator)
  2. Open the Users tab of the admin page
  3. At the bottom of the Users tab, under Personal Options, untick the “Use the visual rich editor when writing” option.

Now you may cut-and-paste the required javascript into any blog post and they will render correctly.

Embedding YouTube Videos in Wordpress and Producing Valid HTML

If you drop the Embed script from YouTube into your blog post, the page will fail a HTML validator. In order to overcome this, drop the following code into your post:

<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/your_video" width="425" height="350"><param name="movie" value="http://www.youtube.com/v/your_video" /><param name="wmode" value="transparent" /></object>

Replace ”your_video” with the id of your YouTube video. There must not be any end-line characters in this code - if you do, wordpress will insert paragraph tags and distort the post (text after the embedded code will be formatted badly on your page).

This solution is demonstrated on this post on my blog.

public/wordpress_youtube.txt · Last modified: 2008/08/09 09:59 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki