Embedding YouTube videos is one of the primary marketing strategies that help it reach the userbase. You can also share it on social media, send it to a chatting app, or even as part of an e-mail newsletter. It’s only a finishing touch, though, because the video production and finishing the uploading is a major undertaking in itself. Then there comes competition since YouTube is a video streaming service that has had, as of February 2020, over 500 hours of video uploaded per minute. So, to boost your chances of “getting eyeballs” on what you produced, let’s dive straight into how to embed YouTube video in WordPress.
What makes embedding possible by default?
The release of WordPress 2.9 2009 introduced a feature called Embeds, which allowed users to embed content from other websites onto WordPress. And, well, YouTube was one of the first adopters, although 30+ services now support Embeds. This makes things drastically easier since no external tools are required. However, you can only embed public and “unlisted” videos or video playlists. With that said, here are 6 ways of embedding YouTube videos in WordPress:
1. Paste a YouTube URL
We have good news; embedding YouTube videos can be as easy as copying the YouTube URL, then pasting it within a page or post editor, whether in Classic Editor (Visual mode only) or Block Editor. This depends on oEmbeds, a protocol that makes website A (yours) ask website B (YouTube) to send the HTML code necessary for embedding. To find the YouTube URL, you can do one of the two:
- Copy the URL in the address bar of your web browser.
- Click on Share below the video. Copy the shortened URL by clicking on COPY.
In the second option, you can put a checkmark in front of Start at and enter a time in the video you want to skip to, and the embedded video will start there.
2. Embed a YouTube video in WordPress with a block (Gutenberg Editor only)
YouTube might temporarily stop responding to requests using the method above. To fix that, add a block by clicking on the “+” button in the top left corner. Now, type one of the following:
1. YouTube block
Scroll down until you find the “Embeds” category, and click on YouTube (or search for “youtube”). Paste the YouTube video URL and click on the Embed button. Use the floating toolbar above to align, change height/width, or add a caption.
2. Shortcode block
This time search for “shortcode” and select Shortcode. Paste this into the newly created block:
[youtube https://www.youtube.com/watch?v=123]. Replace the example URL with the actual URL. Keep in mind that this won’t generate a preview, unlike the YouTube block above. Ergo, you must Preview or Publish the article to see it.
YouTube video customizations inside a block (Optional)
There are times when you want to emphasize a section of the video by defining a start and end time. Also, the default size sometimes doesn’t play well with your installed there or isn’t aligned properly. You can fix all that and more using the following YouTube embedded video optimizations:
- Specify a width (in pixels):
- Specify width and height:
- Left align (you can also right align):
- Start the video at a certain point (in seconds):
- Define start and end time:
- Hide the information bar at the top:
- Only show related videos from the same channel:
- Embed a playlist:
3. Use the YouTube iframe element
If the methods above didn’t work, it’s likely that oEmbed is either disabled and malfunctioning. To bridge that gap, follow these steps to embed YouTube video via HTML code:
- Click on Share below the YouTube video.
- Click on Embed.
- Leave Show player controls checked.
- Optional. Configure Start at like we suggested. You can also put a checkmark in front of Enable privacy-enhanced mode to avoid Google collecting data unless the video is played.
- Highlight and copy the code that starts with <iframe> and end with </iframe>.
- Open the page/post editor, and one of the following:
- Classic Editor: Click on Text in the top right corner. Paste the code in the desired place in the text. Click on Visual to see the result.
- Block Editor: Add a new block. Click on the three-dot toolbar icon, then select Edit as HTML. Paste the code into the block.
4. Embed videos via a sidebar widget
We already explained WordPress widgets, and even taught you to add a shortcode to a sidebar widget. You already have shortcode examples above, so, after adding a function to make it work (if you haven’t already), paste the shortcode into a Text Widget. If that doesn’t work, here’s a quick alternative:
- Go back a step (to the Appearance > Widgets menu).
- Drag the Video widget to the sidebar area on the right.
- Click on the video widget.
- Add any title, then click on the Add Video button.
- Click on Insert from URL, enter the YouTube URL with or without optimizations above.
- Click on Add to Widget, then Save.
5. Add the YouTube video to a WordPress comment
We generally recommend you disable WordPress comments or turn off URL auto-linking in them. Unfortunately, both recommendations go against what this method hopes to achieve. If you must go through this, simply paste the YouTube video URL into the comments. After the comment gets posted or approved, you can watch that YouTube video (or playlist) from the comment section.
6. Embed a YouTube video within WordPress via a plugin
You might wonder, “Why would I even need to install a WordPress plugin at this point?” Well, here are some things WordPress plugins for embedding YouTube videos can do:
- Bring SEO-friendly features for easier indexing
- Embed a representation of an entire YouTube channel
- Generate shortcodes automatically
- Make videos pop-up, autoplay, or loop
- Embed select YouTube video comments
- Dynamic video sizing to automatically adjust between desktop, tablet, and smartphone
- Embed video galleries that also support other video streaming services
- Add scrolling, lightbox, and hovering animations
- Generate custom playlists and thumbnails
- Enable lazy loading and caching of YouTube videos