Embedding a YouTube Video in WordPress

December 22, 2007 | By | Reply More

Here is how to embed a YouTube video in your WordPress blog or website. Copy the embed code for the video from the YouTube page. Switch to the “Code” mode of the WordPress editor and paste in the You Tube code. Then (and this is the trick that was so elusive) put an HTML <pre> tag before the YouTube code and put a </pre> after the YouTube code. The <pre> and </pre> tags keep WordPress from messing up the code. (Note: this may also work for embedding Flickr slideshows, but I have not tried it yet.)

Here is a sample video, I love this song and it is appropriate to the season (Mary Did You Know, performed by Mark Lowry):



Thanks to this post for the idea of using the <pre> and </pre> tags.

Previously suggested solutions to posting YouTube videos include:

  • Turning off the visual editor when editing a post containing a video. This works, but is cumbersome. It is described several places, including this post.
  • Using a code of the following type: [youtube=http://www.youtube.com/watch?v=P0WIJw8JVeU]. This did not work for me. It is described in this post.

Share this post:

Facebooktwittergoogle_pluspinterestlinkedin

Category: WordPress

Last updated: December 22, 2007

Leave a Reply