Adding a YouTube video to a self-hosted WordPress website or blog is fairly easy. All you need is the URL or the embed code provided by YouTube.
The simplest way to add a YouTube video is to copy its URL and paste it into your page. When you do that, the video retains the default size (560px by 315px) and looks like this:
As you can see, this method of embedding a YouTube video into WordPress works well, but it could look better. For example, you might prefer having the video fill the full available width.
To do this, you’ll need the embed code so you can define the settings. The rest of this tutorial explains how to do this.
Get over to YouTube to find a suitable video for your post. This is easy if you’re using your own video. If you’re using somebody else’s but don’t have a specific video in mind, you’ll have to do a little searching.
Enter a phrase into the search box and look through the results for a suitable video.
For this post, I wanted to find a video that appeals to just about everyone. I thought about classic car chases from the movies, memorable TV adverts or some awesome GoPro footage of a base-jumper doing his thing. None of those worked for me.
So, I chose the guy who jumped to earth from the tip of space, Felix Baumgartner. That blew us all away, right?
Now you’ve found a suitable video, it’s time to get the embed code so you can add it to your page.
Look for the Share link, which you’ll find in the menu options over on the left, under the video, and click it:
When you first click Share you will see something like this:
Most of the time you want to start a video at the beginning, but if you want to start it at another place, enter the time in the Start at box (bottom left-hand corner).
To get the code, click on the Embed link.
You’ll see this (the code you need is usually highlighted blue, but I removed the highlight for this screenshot).
YouTube makes its videos available in a few different standard sizes, or you can choose a custom size if you prefer. To access the options, click on Show More.
If you want to use a custom size, enter the width you want (in pixels) in the left-hand box. YouTube automatically adds the height to the right-hand box (you can do it the other way around too).
If you want to use a standard size, choose it from the dropdown menu. When you choose a standard size, YouTube highlights the code for you, if you choose a custom size, it doesn’t (I don’t know why!).
Now copy the code and move over to your blog post.
In your post, there are two types of editor: Visual and Text.
When embedding a YouTube video, you must use the Text editor as you are pasting code. You switch between the two using tabs in the top right-hand corner of the writing area.
Make sure you choose Text, work your way through the post to the place where you want the video to appear, and paste in the code.
Finish editing your blog post in the usual way and hit publish/update. The video will now be inside your blog post so visitors can watch it without leaving your site.
Just like this.
Embedding YouTube videos into WordPress is relatively simple. Once you’ve been through the process a couple of times you’ll become a dab hand and won’t need to refer to this tutorial again.