Gravity Forms Plugin for WordPress

90 responses to “The complete guide to creating widgets in WordPress 2.8”

  1. The Frosty @WPCult

    I’m going to have to read that again when I am not so tired..

    Good write up.

  2. How to create Widgets in WordPress 2.8 | WordPress Philippines

    [...] Justin Tadlock has a nice tutorial on the new way to create WordPress Widgets in WP 2.8. You might remember that in the upcoming version of WordPress the admin interface for Widgets has been revamped, but the method of developing Widgets has been updated as well. [...]

  3. Stefano

    As usual, Justin: great great article!

    Stefano

  4. BuddyPress Links #12 · Buddypress Links

    [...] Completeguide to creating widgets in WordPress [...]

  5. Dicas, Dicas e mais Dicas | pBlog

    [...] Guia para Criar Widgets – tutorial detalhado sobre a criação de widgets para o WordPress 2.8 (em inglês). [...]

  6. J Mehmett

    Enjoy exploring new things and the reason I do love WordPress is that every major release is making even better application.

    Back to the topic, I agree that writing a widget in the WP releases prior 2.8 was really very nasty and unorganized job full of messy functions and dozens of variables.

    I understand things by getting them in my hands first, I have downloaded your code, and it seems as its the sole teacher to understand the tip.

    Thanks for all the good stuff, bro.

  7. The complete guide to creating widgets in WordPress 2.8 | Bloggers Tools

    [...] original here:  The complete guide to creating widgets in WordPress 2.8 You May Like Linking To UsHello and welcome to our blog, you may consider linking to us, because [...]

  8. Good Guide for creating Widgets

    [...] by WP Greet BoxJustin Tadlock wrote a good tutuorial on how to write widgets in Wordpress 2.8. Go here now to check it [...]

  9. Randa Clay

    As always Justin, you rock. I’m mildly techie, but I think with your excellent instructions I could do this!

  10. Matt

    Thanks for the wonderful break down, this helped me recreate two of my widgets so far (twitter and feedburner). It’s so much easier than WordPress 2.7.

    One problem I encountered is adding onfocus, and onblur to an input field, what would be the properly formatted code? Any help would be appreciated.

  11. WordPress 2.8 - Better, Bolder, and Still in Beta

    [...] Tadlock has three posts on WordPress 2.8 already – The Complete Guide to Creating Widgets in 2.8, Custom Taxonomies in WordPress 2.8, and Tag Descriptions in WordPress [...]

  12. Matt

    @Justin: I thought so too, but when I added this value="Enter your e-mail address" onfocus="if (this.value == 'Enter your e-mail address') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter your e-mail address';}". When using the code as is, it gives the following error: syntax error, unexpected T_STRING

  13. Matt

    Thanks for the link Justin, I got it to work.

  14. links for 2009-06-03 « sySolution

    [...] The complete guide to creating widgets in WordPress 2.8 (tags: wordpress) [...]

  15. chantelle tamaris

    WoW this is great. I will have to read it again and try along with it ,but I always wanted to make a widget. Something new to learn about Wordpress. Thanks Mr Tadlock!

  16. WordPress 2.8 for theme authors | The Theme Museum

    [...] to create fake registered sidebars anymore. Just use the_widget template tag. This means you can create a custom widget and insert it anywhere you want. The new widget treatment makes an old dream of some WordPress [...]

  17. leon

    Hi
    Thanks for your guide. I have followed your guide and managed to create multiple instances of the plug-in and had then displayed them on different sidebars.
    But when I try to change the options on one widget on a sidebar … the changes will automatically apply to all the instances of widgets on all other sidebars!?
    Do you have an idea on how to allow the plug-in handle multiple instances of widgets? Or …
    Anyway, I have learnt a lot for the first time about Widget once read this guide. Thanks again
    Leon

  18. The complete guide to creating widgets in WordPress 2.8 | Totally WordPress

    [...] That’s why Justin Tadlock has written “The complete guide to creating widgets in WordPress 2.8″. [...]

  19. WordPress 2.8: Features and tips — gunnerpress.com

    [...] The complete guide to creating widgets in WordPress 2.8 [...]

  20. Wordpress 2.8 And 10 Things That You Should Know Before/After You Upgrade

    [...] Guide to create Widgets in Wordpress 2.8 [...]

  21. Jennifer

    This post was really helpful. Thank you! I do have a question though :) How do you add wysiwyg controls to a widget? I’ve tried taking apart a few old plugins – but they don’t use the new 2.8 widget class, so things get kind of messed up. They also seem to link to their own version of tinymce which doesn’t make sense to me, since there is already tinymce bundled with wordpress… why not make use of that? Hoping you can help… :)

  22. 10 Incredibly Useful WordPress 2.8 Tutorials

    [...] 2. The Complete Guide To Creating Widgets in WordPress2.8 – Justin Tadlock [...]

  23. Jennifer

    I have been able to get tinymce to show up in a textarea of a widget – but when I go to save the widget – it doesn’t seem to save the changes – and then reverts the box back to the non-tinymce view. I’m beginning to think now that this may be some kind of issue with the widget class/feature itself – because that just sounds REALLY odd… I’m not a fan of the wysiwyg editor myself – but my clients can’t do HTML – so I need to have it there for them.

  24. Mikko

    Excellent and easy tutorial. Thanks a lot!

  25. Mikko

    Ok, despite the excellent tutorial, I don’t get it. I’ve created a widget, but when I try to save it, it doesn’t. It looks like it works, but it doesn’t appear on the page and if I reload the widget page, it has disappeared from the sidebar.

    The widget is exactly like your example widget, which of course works perfectly. Any ideas what could cause behaviour like this?

  26. George Serradinho

    I also love the new widgets API and the new features on WP 2.8.

    I have bookmarked this post as I will have to read this a couple of times and try and test to see if it works. I would like to create my own widgets as some plugin developers don’t have widgets for the work.

    Thanks for sharing this :)

  27. 10 İnanılmaz Yararlı Wordpress 2.8 Dersi « - SamsuNkL.Com -

    [...] 2. the complete guide to creating widgets in wordpress2.8 – justin tadlock [...]

  28. Max

    Justin, thanks for the explanation “for dummies” – I really needed it. It seems that WP lacks of better function description and documentation overall… I deal a lot with Drupal, have to say that their API documentation service seems much superior to me than WP.

    Anyway, I’m kinda stuck with updating my own plugin to be compatible with the 2.8 – new widget instances showing up in widgetized areas just fine, but the existing widgets (created in previous WP version) don’t show up and I have no clue why. I output the var_dump for the get_option(”my_widget”) and can see all the existing and the new widgest arrays, but only the new ones show up in the widgets section and the front end. Seems like I can’t even grab their $instance(s). Any thoughts on this?

    Thanks again for the post!

  29. Vasudevbbhat

    Hello ,
    its a very good stuff for widgets but how to add this widget or how to install this kind of widget in wordpress 2.8

  30. Nimesh Kumar

    Thanks

    Great Stuff !!!!!!!!!!!!

    There is nothing getting stuck at any point……….
    I have created lot of widgets using this one structure…….

  31. Jon Pruett

    Thanks for a great guide! I started my first wordpress widget this week with another template that unfortunately wasn’t ready for the 2.8 widget api changes. But in about an hour I transferred over the work I had done earlier and I now have a multi-instance widget saving and retrieving all the settings I need for the widget I’m creating.

    Thank you!

  32. scriptygoddess » Wordpress 2.8 Issues

    [...] Widgets work – including a easier to use API. In light of this, I made use of the new API (armed with this great tutorial and sample file) and created some custom widgets for my [...]

  33. Mark

    Thanks Justin. This was a nice little tute to get me fast-tracked onto making some custom WP 2.8 widgets.

    Cheers!

  34. smsfame.com

    I want to create a widget to send sms, for blog. but I want to give this feature only to registered user, how to get user registration data? how I check user is loged in or not?

  35. Whirled Wind » Blog Archive » My First Wordpress Widget

    [...] I wanted to have for the BookMooch widget. But after searching around a little bit I found another widget template over at Justin Tadlock’s site. By taking the plugin control structure I’d already [...]

  36. Publikační systémy – WordPress 2.8 | Phirebase

    [...] 2.8 Resources For Developers | W3Avenue The complete guide to creating widgets in WordPress 2.8 Wordpress 2.8 And 10 Things That You Should Know Before/After You Upgrade 10 WordPress 2.8 Features [...]

  37. Edgar Doiron

    Can widget be used as part of the loop?

    I’m new to wordpress, so here’s what i want to do.

    Let’s say I have two loops on my page.

    one for displaying important post (6 post)

    another for just daily news (12 post)

    If i’m in the important part and I want to see 6 more post, I click on the page 2 navigation from that section. But I only want that section to reload.

    Are widgets capable of this?

  38. 10 İnanılmaz Yararlı Wordpress 2.8 Dersi « Guncelle

    [...] 2. the complete guide to creating widgets in wordpress2.8 – justin tadlock [...]

  39. Create a posts by category widget in WordPress 2.8 | Your Site is Valid Blog

    [...] Tadlock wrote a very comprehensive article about  making widget in 2.8 and I will use this to make a widget that displays only posts from a [...]

  40. P.Raman

    Hi

    Please tell me how to create a drop-down author list widget, similar to categories widget.

    Thank you.

  41. links for 2009-07-03 — Chroniques du web

    [...] The complete guide to creating widgets in WordPress 2.8 (tags: wordpress widgets howto widget development reference tutorial) [...]

  42. WordPressMU 2.8.1 now out, features and a couple bugs - WPMU Tutorials

    [...] still work, but you no longer have to specify them for multiple use. They all are now. Check out the complete guide to creating a widget from Justin [...]

  43. Stéphane Gallay

    It looks like a neat tutorial, but I’m missing something I haven’t been able to find in any tutorial, namely where do you save your widget code?

  44. Ditutu

    I’ve created my first widget after reading this post,a widget which shows if the owner of the blog it’s able for freelancer . It’s a very good tutorial ,you are great .

  45. Edgar Doiron

    @Justin -
    http://coffeeman.name/wp_test/
    let’s say i want two navigation, one for the top part and one for the bottom part. And having them work independantly?

  46. New And Comprehensive Wordpress 2.8 Tutorial and Hack Toolbox | Graphic and Web Design Blog - Inspiration, Resources and Tools

    [...] 11.The complete guide to creating widgets in WordPress 2.8 [...]

  47. Johnny Goodperson

    Thanks for your tutor mate :)
    i’ll make it :D

  48. Today’s Delicious links - 27/05 | Links | WereWP

    [...] The complete guide to creating widgets in WordPress 2.8 [...]

  49. New And Comprehensive Wordpress 2.8 Tutorial and Hack Toolbox - Programming Blog

    [...] 11.The complete guide to creating widgets in WordPress 2.8 [...]

  50. Joe Random

    Good post for blogger beginners and particularly i like your template which seems to be very elegant for me…

    Thanks for sharing and many more years to come/ your friend krishna das

  51. Joe Random

    Sorry, one more time- why you’ve not added any ads?

  52. Kevin Baker

    As a blogger who spends hours playing with WP I found this intriquing.

    I am not a comuter prog techie sort but i could follow these instructions and make a good attempt. Maybe i should do that.

    Thanks for the share.

    Kevin

  53. JNFerree

    I knew there was a good reason why this article/post was in the Top 10 on Stuff-to-Tweet. Nice job Justin. Since my cracker skills are meager at best, I figure I’ll have to send my Rent a Coder buddy here so he can brush up on your How To Make a Widget Work in WP

    How many of your reader’s have asked you what your hourly rate is? BTW, what is it?

  54. links for 2009-07-24 » 4exp.net

    [...] The complete guide to creating widgets in WordPress 2.8 (tags: wordpress tutorial webdevelopment widgets wordpress_widgets) [...]

  55. Joe Somebody

    Excellent guide to start with wordpress . At firt i feel so tired . Nowwith this tutorial everything is clear .

  56. David Rios (dfrios) 's status on Monday, 27-Jul-09 20:03:34 UTC - Identi.ca
  57. cas

    This is fabulous! Thank you so much!

    One point of confusion though – there is a discrepancy between the code you show in the post, and the code inside the downloadable example –

    /* Display name from widget settings. */
    		if ( $name )
    			echo 'Hello.  My name is' . $name . '.';
    /* Display name from widget settings if one was input. */
    		if ( $name )
    			printf( __('Hello.  My name is %1$s', 'example'), $name );

    What is the difference between using echo and printf (besides printf using more code)?

  58. Laura

    Justin, many thanks for the tutorial – I looked a lot to find how to do this.

  59. Jane Doe

    Great and complete tutorial Justin,like always thank you!

  60. GTRway

    Do you know any special plugins to create these widget .That might save a few minutes since i am not much familiar with php and other code?

  61. cas

    Ah ha! Well, now that makes sense. I see that I have a lot to learn yet about plugins and widgets and Wordpress in general – Thanks so much for taking the time to explain that! :)

  62. Jeff @ Code Research Center

    Thanks that was just what I needed
    You created a nice and clean example that was very easy to follow.
    I did have one issue but it wasn’t with your code it was with the text editor(visual studio) I was using, switched to phpDesigner and now everything works fine.

  63. Adam

    Very good tutorial for me as a newbee.
    I wonder is there any program or plugin to make widget in wordpress?.

  64. Adz

    Hey
    I just want to say thank you! Once I followed it through bit by bit, I began understanding it a lot better, and I’ve nearly completed my first widget.

    Oh, and a little tip for anyone else trying to learn this stuff – don’t just copy paste it. Type it all out bit by bit – it’s invaluable to understand what’s actually going on. That’s applicable to anything really, not just WordPress.

    -Adz

  65. Gaurav

    Hello Justin,

    I go through your most of the articles and frankly speaking, those are really nice..
    I hope you can solve my one problem.

    I have a plug-in named MM Snippet.
    In Appearance section on widget link, we have list of available widget to be displayed in side bars. In the bottom of the page, the plug-in provides no of Snippets.
    see this link :
    http://www.drivehq.com/file/DF.aspx/376855287.gif?isGallery=&share=&shareID=0&fileID=376855287

    Now the problem is that in available widget page only one snippet is shown. Rest of the snippets are ignored by a condition in function wp_list_widgets()
    This function resides in wp-admin\includes\widgets.php file.

    If I comment the below lines, it works great but I am limited to plug-in only.
    if ( in_array( $widget['callback'], $done, true ) ) // We already showed this multi-widget
    continue;

    I can’t touch the wordpress core code.

    Kindly help..

    Thanks,
    Gaurav

  66. Gaurav

    Deleted by the administrator. Please don’t post the same comment twice. This is not much different than having to deal with spam comments on a daily basis.

  67. Gunjan

    Gr8 stuff….will surly try it out…..sweet and simple

  68. Sarah

    Hello Justin, first let me say how usefull I have found this tutorial.

    Now I managed to follow it and create my own widget succesfully but one little thing. I have a select drop down with options and when I select an option other than the default and hit save although it does save and displays my selection correctly the option in the select drop down (in the widget box-admin) reverts to the default. I think that is confusing for users.

    Then I though let me try your example and see if that happens with your example widget and how strange. It does! I choose female from the drop down and it does save and display correctly however the option in the drop down still shows male.

    Is there a way to fix this little detail? I appreciate any responce to this.

  69. Links for August 11th

    [...] The complete guide to creating widgets in WordPress 2.8 – An excellent article from Justin Tadlock, a WP Demi-God. Related Posts:Links for December 15thLinks for July 17thLinks for June 16thLinks for August 4thLinks for February 9th Share This: [...]

  70. Create a Social Links Widget in WordPress 2.8

    [...] reading Justin Tadlock’s tutorial: The complete guide to creating widgets for WordPress, I have created eleven custom WordPress 2.8 widgets. It’s actually quite simple, much easier [...]

  71. Trabajo

    Very good tutorial for me, I wonder is there any program or plugin to make widgets for wordpress blogging platform.

  72. Webdesigner

    Wow, thanx for this tutorial! I can’t wait to get my hands on this at evening!

  73. willsy

    Very nice tutorial. I am trying to extend this and provide file upload by adding a new form item with type=”file”. My form displays and I can choose a file to upload, however I don’t know how to pull out the file information in the update() method. I also cannot find a single example of a 2.8 widget with file upload capability. Any pointers please ?

  74. Raymond

    Here is one for you. Used this code to develop a plugin for use with my Wordpress MU install. The problem is though that when I change the values of parameters on one blog it changes it on all of them.

  75. Edward Caissie

    Just wanted to say “Thanks” for this post, I found it very helpful with adding / creating widget functionality in the plugins I recently wrote.
    Since reading this post a week and a half ago, I have been able to put three plugins into the WordPress repository.
    Kudos to you!

  76. World of Wordpress at Helpful Technology

    [...] The complete guide to creating widgets in 2.8, Justin Tadlock [...]

  77. 10 Most Helpful WordPress Design Blogs | Cosmos Blog -- Internet News,Life,Culture,Polices,Resource,Make Money

    [...] The complete guide to creating widgets in WordPress 2.8 [...]

  78. Len

    Hi,

    I could not find any information on how to install new widget (not present in WP 2.8.4)
    I downloaded a new widget, but don’t now where to put it. Does it go to a theme directory?

    Thanks

  79. Dustin Dempsey

    @ Len,
    You add the file to your plugins directory or add the coding to the bottom of your functions.php file in your theme’s folder (This would make it only available on that theme).

    Thanks for the writeup. It helped me out a lot.

  80. Darshana Gunawardana

    This is great. Specially very good tutorial for me.
    Thanks….

  81. Ten Tips for Becoming a Better WordPress Developer | Web Design Ledger

    [...] For more information on how you can write your own WordPress widget, Justin Tadlock wrote up an awesome article on the subject. [...]

  82. Tutorial: Widget selbst erstellen (Wordp… | Wordpress Lesezeichen

    [...] Widget selbst erstellen (Wordpress 2.8) http://justintadlock.com/archives/2009/05/26/the-complete-guide-to-creating-widgets-in-WordPress-28 Tweet This!Share this on TechnoratiSubmit this to NetvibesAdd this to Mister WongMark this on [...]

  83. CHRISTMAS 2009 − Links for 2009-11-10 [del.icio.us]

    [...] The complete guide to creating widgets in WordPress 2.8 have seen some good tutorials on creating widgets for WordPress 2.8 floating around the WordPress-o-Sphere. But, I didn’t feel any of them really covered practical usage. I want to show you how to create a widget for real-world development using WordPress 2.8’s new widget class. [...]

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution. Please use your real name or a pseudonym (e.g., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.

Recommended Purchases

Gravity Forms Plugin for WordPress 'Digging Into WordPress' book for WordPress users

WordPress-o-Sphere

  • WordPress 2.8 – "Baker"
    WordPress 2.8 adds hundreds of bug fixes, adds cool functions for themes, boasts a new widget API, and makes custom taxonomies easy for end users.
  • WeRockWP
    WeRockWP recognizes and showcases the individuals who contribute much to the WordPress community. These individuals are called WordPress Rockstars.
  • wpazo
    The all-signal, no-noise, source for the best WordPress stuff.
  • BuddyPress 1.0 has arrived
    The long-awaited BuddyPress (a set of plugins that turns a WordPress MU install into a social network) has been officially released.
  • BuddyPress for WordPress (not MU) coming
    It looks like BuddyPress will also be released for normal WordPress installs (not just WPMU).