Embedding a YouTube Video in WordPress

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:
    This did not work for me. It is described in this post.

Share this post:


Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.