WordPress embeds – use them folks!
Old habits die hard, especially if no one told you there was a better (easier) way of doing things. Before WordPress 2.9, released in December 2009, if you wanted to add a YouTube video to your post you had two options:
- Copy entire video embed code, paste it to your post while in HTML view or
- Use a plugin that lets you paste just video ID, or some other part of its URL either into a special field or shortcode
I probably would never even write this post had I not received several emails lately, all from tech-savvy site owners, asking me why contributors are unable to add YouTube embed code to posts. The answer to the question is actually quite simple – contributors can’t add any kind of HTML to posts, but the fact such question was asked meant two more people unaware of this great WordPress feature.
So, if you wanted to embed a YouTube video, instead of doing this:
<iframe width="640" height="480" src="//www.youtube.com/embed/IXM2wykRexM" frameborder="0" allowfullscreen></iframe>
All you need to do is paste YouTube video URL on its own line, and the video gets embedded automatically:
Works with videos hosted at Vimeo, Viddler, Hulu, FunnyOrDie.com, DailyMotion, blip.tv and WordPress.tv as well. But that’s not where it stops. You can also embed Tweets:
Ticket, flight and hotel booked, see you at #wceu
— Slobodan Manic (@slobodanmanic) August 31, 2013
And lots of other services. Other than convenience, there’s two major reason why you should do it this way:
- It’s how WordPress expects you to do it, meaning this is 100% future proof and
- If YouTube ever changes its embed code you’ll have to check each post and update the code, not a potential problem you’ll have to think of if you’re using nothing but URL, which is very unlikely to change
Yes, you can still use a plugin, paste video URL into it and let it embed a video for you, but as Occam’s razor states, all other things being equal simplest solution is almost certainly the best one and this is no exception. So how do you embed your videos?