Videos are a fantastic way of enriching your website content and keeping visitors on your pages longer.
There are many video services online, but YouTube is by far the largest, hosting millions of videos and delivering billions of hours of video content every day.
In this article, I will show you how you can integrate YouTube videos into your WordPress posts, pages and custom post types.
Whilst YouTube is the primary focus of this tutorial, please be aware that the steps outlined below will work with other video platforms such as Vimeo, Facebook and DailyMotion.
Check out the WordPress embed page for a complete list of which video and image platforms are supported by WordPress.
Find the Video URL
In order to display a video on your website, you need to know its URL.
I will use the WinningWP YouTube channel as an example.
Simply highlight this URL and click to copy.
You can also retrieve the video URL by clicking on the share button that is displayed underneath YouTube videos.
The YouTube share box lists the video URL and gives you the option of sharing the video on around a dozen social media platforms.
There is also an option to start the video at a specific point.
If you click on the embed button, YouTube will display the HTML code for displaying the video in an iframe.
Since YouTube automatically inserts the necessary HTML code for videos into posts and pages behind the scenes, you only need the URL of a video in order to display it on your website.
You can, however, use the iframe HTML code to integrate videos directly into WordPress page templates.
Once you have the video URL, you are ready to publish the video on your website.
Displaying a YouTube Video – The Quick Way
When you are using the WordPress editor, you will see a message that states “Start writing or type / to choose a block”.
If you paste the YouTube video URL into this box, WordPress will automatically add the video into your content using the YouTube block.
It is the quickest and easiest way to add a YouTube video into your website and the YouTube block allows you to adjust the alignment of your video and display a caption underneath.
Displaying a YouTube Video With the YouTube Block
Copying and pasting a YouTube video URL into the WordPress editor will automatically create a YouTube block using the video URL.
If you prefer, you can add the YouTube block manually.
One way to do this is to simply type a slash (/) to see a list of available content blocks and then select YouTube.
Alternatively, you can insert a YouTube block into your content area by clicking on the + symbol at the top-left hand side of the editor and then selecting the YouTube block from the embed section.
You can also find the block by searching for YouTube in the content block search bar.
The YouTube block is simple to use.
All you have to do is enter the URL of the YouTube video you want to insert into your content and then click on the embed button.
Once you have embedded a video, an edit URL button button is displayed above. Clicking on this will take you back to the section where you enter the video URL.
The Genius of WordPress
The WordPress block editor is extremely intuitive.
If you enter a YouTube video URL into a WordPress embed block or video block, it will change the block to a YouTube block for your video.
WordPress does this with other video platforms too.
For example, if you enter a DailyMotion video URL by copying and pasting the URL or by using an embed block or video block, WordPress will change it to a DailyMotion content block.
Dozens of video and image platforms support this feature.
WordPress has fantastic support for YouTube and other video platforms.
The developers of WordPress have simplified the process of integrating videos into your website by supporting copy and paste, however you can still insert videos directly using content blocks if you prefer.