Embed a YouTube video

You can use shortcode to embed a YouTube video into your WordPress post or page by getting the video ID directly from YouTube.  I’m going to use the following video as an example

http://www.youtube.com/watch?v=W6t496YLDy4

The video ID is everything that appears after the ?v= in the YouTube URL so to embed this video into our post is simply a matter of this

Advanced Use

The default size is 480 x 390 but you can further extend this by adding width and height attributes. One of the easiest ways to do so is to look at the embed code and take the sizes from there.

As you can see in the bottom of this image, there are a number of size options which, on selection, will alter the embed code. Now, looking closer at the embed code you’ll see a width and height attribute along the second line.

Take note of these two and add them into your shortcode as follows