WordPress Complete(Sixth Edition)
上QQ阅读APP看书,第一时间看更新

Adding videos to blog posts

Luckily for us, the process of adding a video to a standard blog post or page has been made as easy as possible. Let's discuss this step by step.

We're going to start by creating a whole new post. The title we can use is, Great Baby Back Ribs Recipe. Creating the post itself is pretty basic. All you need to do is navigate to Posts | Add New. You'll see a screen that we've already covered earlier in this chapter. Let's put some example content in place, and try including a video right away. All we have to do in order to achieve this is copy and paste the URL of the video that we'd like to have included in our content. Just a standard copy-and-paste, and nothing else.

When copying the URL of the video, it's important to make sure that the link is copied as-is in raw-text form (not hyperlinked anywhere: that is, not clickable).

The example I'm going to use here is the video at http://www.youtube.com/watch?v=hDyHbTxTL-A.

As you would have guessed, it's a nice video recipe for some baby back ribs! So in order to include this video in a blog post, all I need to do is take its URL and just paste it in. This is the raw-text content of the new post that I'm working on now:

Here's a great video recipe for some killer baby back ribs:

http://www.youtube.com/watch?v=hDyHbTxTL-A

(by Laura Vitale)

Now, when I save such a post, the URL of the video will be turned into a live video automatically. This will happen both on the front page of the website and even on the Edit Post screen itself. Refer to the following screenshot:

To give the post some more unique presence, I also added a new category, Recipes, and I assigned the post to a new content type, Video. This is done through the sidebar on the Edit Post screen. We will talk more about different content types later in this chapter. Take a look at the following screenshot:

The process described here explains how to embed YouTube videos and make them a part of your blog posts, but the same goes for other popular platforms like Vimeo, TED, Hulu, WordPress.tv, and others. To get the full list of the supported platforms, please visit https://codex.wordpress.org/Embeds.

One more method of adding videos to blog posts, which we left out initially, is uploading the raw video files manually (instead of using a third-party platform like YouTube). Although this is possible in WordPress, you can drag and drop a video file just like you'd do with an image, it's not a recommended solution. Video files are always quite large in size, and having them hosted on your standard web server can become very expensive (bandwidth costs), should the video become popular and end up being viewed by thousands of people. It's a lot more efficient and user-friendly to just upload your video to YouTube or a similar platform, and then have it embedded on your site, like we've explained a minute ago.