YouTube Videos In WordPress Blogs Disappear if You Edit the Post

February 23, 2008 by · 4 Comments
Filed under: Word Press, WordPress Tips, YouTube 

I was having the hardest time trying to insert YouTube videos into my blog up until recently.  I would type the post, and then switch over to the “Code” tab and insert the YouTube code, then save the post and all was fine.  But if I wanted to edit the text of my post, as I almost always do, the video would always disappear from the post after making my changes.  I knew I had put it there; I remember inserting the code!  But where did it go?

Then I remembered that, for some reason, WordPress tends to think it “knows better” than you do when it comes to code!  I was fighting with it a few weeks ago because it kept removing the line breaks I was adding in the “Code” section!  And what I had figured out was that, if you add or change something to the “Visual” tab AFTER changing or inserting something in the “Code” tab, you are likely to lose some of the Code changes.

Why does it do this? I don’t really know. WordPress is genius, I do admit that. And what it knows about code could blow me out of the water any day, I am sure. But sometimes I DO want to be able to add an extra line break here and there or insert a YouTube video or something. I do believe this is a true glitch that needs to be fixed.

Anyway, while I don’t know why it does this, I did figure out a workaround for it. Just make your code changes the very last thing you do before you hit “publish.” This sounds simple, but it can be kind of a pain sometimes.

The greatest difficulty I’ve come across in working around this glitch is mainly one of inconvenience. Say you made a blog post yesterday and inserted a video. Then today you notice a typo in your post and want to fix it. Unless you saved the embed code from YouTube in a text file on your hard drive or something, you’re going to have to go back to YouTube and get the code again and come back to WordPress so that you can add the code to the Code tab again after making your editorial changes on the Visual tab.

If you have any questions about inserting a YouTube video into a WordPress blog entry, just use the contact form (link is over on the left) to contact me. I’ll help as much as I can!