WordPress YouTube Widget

Number 7 in Widget-A-Day is a YouTube widget.

It’ll display a YouTube video in the sidebar. Just enter the URL of the video, and it’ll show in the sidebar. You can change the width and height, and make it autoplay or not.

Download youtube.zip

SVN Checkout
svn co http://svn.wp-plugins.org/youtube-widget/trunk

Default display:

Admin panel:



  1. Download youtube.zip
  2. Extract and upload youtube.php to the plugins/ directory
  3. Enable YouTube Widget in the Plugin admin panel
  4. In widget admin panel, place YouTube in the sidebar, and edit it to enter the YouTube URL, not the embed code

Download youtube.zip

96 thoughts on “WordPress YouTube Widget”

  1. i just installed this in my blog with zero problems, love it! now i should probably started posting more on youtube instead of daily motion. thanks for a really great great plugin!

  2. Hmm, it seems it doesn’t, but regular embeds straight from Youtube also aren’t working for me in IE6. I think it might be a Youtube problem.

  3. Great plugin, works fine in Firefox, Camino and Safari.

    I would love to see capability to have multiple instances of the widget. A few other plugins other than the standard Text and RSS do it.

    Thanks for making this.

  4. Hi,

    This looks like a great widget. Unfortunately, I can’t use widgets in my sidebars, as I’ve already got them set up with various plugins, etc. Therefore, I was wondering if I could just use it as a plugin; that is, paste some code into my sidebar rather than using the widget panel.

    Thanks again

  5. Yup, probably because I’ve never used them.


    $videoid = str_replace( array("http://www.youtube.com/watch?v=", "http:/youtube.com/watch?v="), "", $options['video']);


    $videoid = str_replace( 

    Should do the trick.

    Note: I should just do a reg-ex, but I tried doing it quickly and it didn’t work right in the 2 minutes I worked with it, so I said screw it. I’ll have a reg-ex one real soon now.

  6. Hi,

    Is this incompatible with WP 2.0.4? Or is there a minimum size for the youtube videos (my sidebar requires things to be 160 px wide or less)?

    It’s not working for me. And I wish it would!

  7. The plugin installed perfectly. However,I noticed that after trying to change to a new youtube video, it didn’t work. I took a look at source code and for some reason it tries loading the URL in the same string instead of just taking the video id….

    If this happens to you just copy the video id which is everything after the “V=”


  8. The removing of the YouTube URL is quite dumb. It should be a reg-ex, but I got lazy. If anything is slightly different with the URL, even case wise, it won’t work right.

  9. hi!
    i can’t drag & drop my wigets on the sidebar..
    Pleas, Can you give me the php code to insert manually the widget in my sidebar.php and the parameters tha i have to change in the youtube.php?

    thanks a lot!

  10. thanks. great widget. One thing I’d like to see is an option to have it on the main page or subpages online. NextGen widgets have that feature. I’d like to have video on the main page, but not on the subpages.

    Anyway, great widget. simple, clean. very cool.

  11. I install the youtube.php and when I go to activate it this error comes up every time:

    Warning: Cannot modify header information – headers already sent by (output started at /home/scoopgro/public_html/dblog/wp-content/plugins/collapsing-categories/collapsCatList.php:200) in /home/scoopgro/public_html/dblog/wp-login.php on line 202

    Warning: Cannot modify header information – headers already sent by (output started at /home/scoopgro/public_html/dblog/wp-content/plugins/collapsing-categories/collapsCatList.php:200) in /home/scoopgro/public_html/dblog/wp-login.php on line 214

    Warning: Cannot modify header information – headers already sent by (output started at /home/scoopgro/public_html/dblog/wp-content/plugins/collapsing-categories/collapsCatList.php:200) in /home/scoopgro/public_html/dblog/wp-includes/pluggable.php on line 689

    I don’t know what is happening. This also happens when I try to log in.

  12. Fatal error: Call to undefined function: str_ireplace() in /home/XXX/public_html/wp-content/plugins/youtube-widget/youtube.php on line 110

    Any ideas why this might be happening?

    I was unable to clearly add it to my sidebar widget, am I doing something wrong?

  13. I would guess str_ireplace doesn’t exist in your environment. You’re probably running PHP 4, which it apparently isn’t in, and I didn’t know when I changed it to this. You can try changing it to just str_replace, and it should work. I’ll update it to fall back to str_replace when str_ireplace doesn’t exist.

  14. I diden’t done any extra. I just got WP 2.5.1 installed and draged the the youtube widget v 1.1 into the others and when I want o save that in the widgets I got an error:

    Fatal error: Call to undefined function: str_ireplace() in /home/.cacaodryer/oweibel/wasabi.li/wp-content/plugins/youtube.php on line 110

    And after that the youtube widget is deleted from the list …

  15. Hi, I like the plugin very much but I have the following problem: after I first have installed it, it worked without any problems. Yesterday I decided to change the title form My video to a title in Bulgarian /written with cyrilic letters/ and the video disappeared. I deleted the title and returned it to My video, but the plugin doesn’t work anymore like it used to.

    What did I do wrong and what should I do to correct it because I want my video plugin to work in the sidebar.

  16. I would like to thank you for writing this plugin.It works just perfectly on 2.5.1 for me, I am using the Insense Theme by Design Disease. Yup… the plugin works! I am not a WordPress geek, but I do know that minimum server requirements for a lot of plugins require php 5 these days (at least to get the “best” functionality out of them).As far as themes are concerned.. well issues can arise out of there too. So as far as plugin development goes, the authors of the script can no way give end users absolute assurance to the tune of compatibility and do us a great service. Thanks Again.

  17. Lovin’ this widget! Just have one question. On your example of how the youtube player will look, your play bar is all nice, small and red. When I install my youtube widget the play bar is big, ugly and … gray. What could cause the difference in appearance for this? Would it have anything to do with the style one is using for their site (.css) I’d reeeally like to have my play button, progress bar, volumn, etc. look nice a tiny like yours. I’m having to size my video down quite a bit since my sidebar is not terribly wide, so having a huge, gray play bar looks pretty nasty. THANKS for creating this youtube widget! It’s still my favorite one that I have tried!!

  18. Hi, was just wondering how I could call this block manually? I want it to appear as part of my header instead of in the sidebar. Is it possible?

  19. Just wanted to tip off anyone looking here with the “call to function” error- search for “str_ireplace” and change it to just “str_replace” (without the “i”) and it should work again.


Leave a Reply

Your email address will not be published. Required fields are marked *