Hosting Tutorial & Guide

How to Embed Videos in WordPress Posts and Pages

updated on Oct 26, 2015
How to Embed Videos in WordPress Posts and Pages Embedding videos in posts is a great way to enrich the content and improve user experience. Sometimes, a 15-second video works better than 500 plain words. A well-crafted video is even better as it can impress your site visitors and change the way they react to your posts. Also, some big brands are trying using video as the backgrounds of their sites.

If you are about to add the first video on your WordPress site, you should be thinking about the answer to several questions, such as "can I embed a video from YouTube or should I upload the video to my site?", and "how to embed YouTube videos easily?". This post will answer all these questions.

Should You Upload the Video to Your Site?

Assumed that you have already made a video and plan to add it in a post, the first question to work out is whether you should upload the video to your site as a media file, or you have to host it somewhere else. To be honest, both methods have their own benefits, but we would suggest the latter option more for most WordPress users.

Uploading videos

If you upload the video to your site directly, you can indeed prevent the common problems brought by YouTube videos, such as ads and the display of related videos. However, there are many disadvantages.
  • The video can consume a large amount of disk space and much bandwidth. If your site is on a shared server, a video can cause a heavy burden on the resources even if it is visited several times per day, not to mention that you may need to upload more than one.
  • The situation can get even worse if your videos are hot-linked by others.
  • There is always a file size restriction specified by hosting providers, which means you may not be allowed to upload the video to your site.
Regardless of these demerits, uploading videos has its benefits, such as the complete control, the exclusivity, and the contribution to SEO. Therefore, this method is only considerable for those webmasters who use a good VPS or a dedicated server with sufficient resources. Shared hosting users, however, should not upload videos to their WordPress sites for the limited server resources.

Host videos on YouTube or Vimeo

Compared with uploading videos, this method can exactly get the demerits covered. Since the videos are hosted on another site, they do not consume the bandwidth of your server. Therefore, even if you have several popular videos visited 100 times per day, your site speed is not badly affected. Also, the servers used by sites like YouTube or Vimeo are specially optimized for serving videos.

In addition, you can enjoy the following benefits when hosting videos on third-party sites.
  • Get additional traffic on the video sites themselves.
  • Offer visitors the ability to select the video quality (resolution) based on the speed of individual Internet connection, which guarantees them a good experience.
  • Do not need to worry about the compatibility with web browsers and mobile devices.
Generally speaking, this option is the better choice for all shared hosting users and those webmasters who do not want to manage videos on their servers.

So in below, we will mainly introduce how to embed the videos on third-party sites in a WordPress post/page. YouTube is picked out for an example since it is the most popular video sharing site.

Embedding a YouTube Video

This task is more than easy with the built-in oEmbed feature introduced in WordPress 2.9. When you have to add a video, you only need to copy its URL and paste it in the post editor, and oEmbed will point the URL to the video automatically. No code is required. But remember, the URL must be in its own line and not hyperlinked. Below is an example.

Embed a Video with oEmbed Feature

After the URL is properly placed, you get a live preview if you are using the visual editor. For the text editor, you can preview the post/page to see the video.

Live Preview

If you are not satisfied with the width or height and want to make them match your website design, you can adjust them by using a simple [embed] shortcode. The shortcode can be used in this way.

Change the Width and Height

Embedding a YouTube playlist is the same as embedding a single video, but be sure that you have copied the full URL of the playlist.

Besides YouTube, oEmbed also supports some other third-party sites. It comes with a whitelist, and only when the site is included in the list, can you embed the video URL directly into the post. The list includes Vimeo, WordPress.tv, Tumblr, Flickr, Vine, TED, Hulu, DailyMotion and more, and it is growing as the new versions of WordPress are rolling out.

oEmbed offers the easiest way for embedding videos, but there is an obvious drawback. The feature does not provide you with additional options for customizing the video except for the adjustment of width and height. These options include autoplay, the start and stop time, and related videos.

Customize YouTube video

If you are using Jetpack on your site, the customization problem of oEmbed can be easily solved. Jetpack allows you to append parameters after the video URL to define several customizations. But first of all, you have to go to the settings page of Jetpack and activate the "Shortcode Embeds" feature.

After the successful activation, you can start customizing YouTube videos. Below are some examples of the parameters you can use. Note that you need to replace the "URL" with the URL of your own video.
  • Specify the height and width: URL&w=700&h=400
  • Left align the video: URL&align=left
  • Specify a start time: URL&start=90 (as all the time is calculated in seconds, "90" means the start point is 1 minute 30 seconds)
  • Use the light theme: URL&theme=light
  • Set a video left-aligned, starting at the 30th second and using the light theme: URL&align=left&start=30&theme=light

Turn off the related videos

When using YouTube videos in posts, the related videos are annoying and make your site less professional. Turing off this unneeded feature is easy. If Jetpack is installed and the "Shortcode Embeds" is activated, you can append the parameter "&rel=0" at the end of the video's URL.

Turn off Related Videos

What if you are not using Jetpack? There are still two solutions. One is to install a plugin like Hide YouTube Related Videos which disables the related videos automatically. And another is to manually embed YouTube videos into WordPress with the embed code instead of using the oEmbed feature.

If you choose the latter method, you can add a video successfully into your WordPress post/page without displaying related videos by following these steps.
  1. Open the video your want to embed.
  2. Under the video, click on the "Share" option, and then click the "Embed" tab.
  3. Uncheck the "Show suggested videos" option, and choose a proper video size.
  4. Copy the embed code and paste it in the place where you want the video to display.
Embed a Video Manually

A good plugin for embedding YouTube videos in WordPress

In the case that you do not use Jetpack but still want the customizations, you can use a plugin that is designed for video embedding. Since there are not many good choices available, we recommend the one named YouTube Embed.

This plugin is simple to use but very powerful. It offers a shortcode [youtube] to allow you to embed and customize YouTube videos. By adding parameters to the shortcode, you can change the width and height, control the audio, disable related videos, specify the start and stop time, etc.

Download: https://wordpress.org/plugins/youtube-embed/

YouTube Embed