Embedding Youtube Videos in WordPress Posts

Posted by on Apr 2, 2008 in General, Wordpress, Youtube

I’ve had problems with embedding Youtube videos in WordPress blog posts in the past, and since I don’t post videos often enough to remember the solution I end up researching my problem each time. Now that I’ve got the solution down I figured I’d share it with you in case you run into the same trouble. I haven’t upgraded to WordPress 2.5, so I’m not sure if the fix is already be built in the newest version. If it is fixed in newer version then this only applies to older versions of WordPress.

There are two solutions to the problem:

1. Turn off the Visual Editor in your user options

2.  Keep Visual editor on but switch to Code mode when posting YouTube embed code

Turning off the Visual Editor

What seems to be messing up embeded YouTubed videos is WordPress’ Video Editor. The simple solution is to just turn the visual editor off. To do this simply go to Users -> Your Profile,  then uncheck the box that say “Use the visual editor when writing”. This may be a hassle if you want to use the visual editor to edit the post or even edit other posts, because you would have to keep turning the visual editor of and on. The other solutions is to…

Keep Visual editor On But Switch to Code Mode When Pasting YouTube Embed Code

To do this just write your post as you usually would, but wait until you are just about ready to publish your post to insert the Youtube video. When you have done everything except insert your Youtube video, just switch to Code mode (click on the tab next to “Visual” just below the Title box), and paste your Youtube embed code while in Code editing mode. Then click the publish button without going back to Visual mode. It is important that you do this very last, because if you go back to Visual mode your Youtube embed code will get messed up by the WordPress Visual Editor.

So, basically just avoid using the Visual Editor if you don’t want your embeded Youtube videos to get messed up. If you need to ever go back and edit a post with an embeded YouTube video make sure to re-paste the emded code while in Code mode if you use the Visual Editor to edit the post.

I plan to upgrade to WordPress 2.5 in the coming weeks so if there is simpler solution or if the problem has been fixed in that version I will let you know. Please comment with your own experience if you have already used WordPress 2.5 to post Youtube videos.

7 Comments

  1. 4-3-2008

    Chris,

    I had the same problem as well. Like you, after searching online with all of the helpful info I was able to solve the problem!

    Man I love the blogosphere!

  2. 4-3-2008

    Yeah, Isn’t the blogoshpere great. Thousands of people all writing and discussing in the open, one of them is bound to have the answer you are looking for.

  3. 4-3-2008

    Hi Chris, I upgraded to WordPress 2.5 last night and so far so good. FYI, the new Visual Editor apparently doesn’t screw with your code anymore, so hopefully issues like this will be a thing of the past.

    I just posted a test video on my site, and it works great. WP2.5 also has much greater media support than previous versions… not entirely sure what that entails yet but I know you can upload entire photo galleries all at once instead of one at a time now.

  4. 4-3-2008

    Thanks for letting us know, Jonathan. I have installed WordPress 2.5 once (not on this blog, though) and did notice the little media buttons, which is what made me assume that this YouTube problem would be fixed. Didn’t have time to actually try it though, so thanks for sharing your experience.

  5. 4-4-2008

    Hi Chris,

    I just tagged you in my 8 Little Thinks Know about me post! Check out my blog for the details!

    Have a great day!

  6. 4-5-2008

    Hey Chris,
    Thanks for sharing this! It’s always been a problem when trying to get the videos embedded and like you I always have to look it up. Think I’ll place this in a word doc and keep it in “my docs” for further use.
    Thanks again.
    -Jon

  7. 9-25-2008

    Funny, I’ve been dealing with the same issue. It’s got the point to where I don’t even want to go back and correct a spelling error, just to avoid that youtube issue. just use another video service other than youtube.

potent