What are WordPress Widgets?

I’m not a big fan of newspapers. Planets will line dance before I read more than a handful of column inches in any given rag. One of my beefs with print media is that I can’t customize it. Sure, I can tear up a newspaper and shuffle the parts around on my kitchen table but the parts never fit together again.

Enter WordPress Widgets. A few hours ago, Matt launched this little feature that we designed and I wrote. This may not be a time for comparing small steps to giant leaps but it’s still pretty cool. Widgets are sidebar elements that you can move into or out of, up or down your sidebar any way you like. This sidebar thing is starting to sound like fun!

Matt mentioned that we’re taking requests and opening an API. Of course, not every request can be honored but we’ll try to include the most popular wishes as time goes on. This is part of what’s so nice about having an open API: any programmer can write a widget. It’s really just a mini-plugin.

Programmers: before you get all excited about writing the next big sidebar widget, you should know that the API (which is painfully simple) isn’t done yet. This is mostly due to the differences in sidebar markup between themes. We’re beefing up the API to handle this diversity but rest assured that the API will be very familiar: write a function or two, use a couple of new hooks, stick a fork in it.

15 thoughts on “What are WordPress Widgets?”

  1. Pingback: vertino.blog
  2. I’ve been looking for 10 minutes at all these connected blogs and haven’t seen a widget link yet.

  3. Andy,

    What do I as a theme developer need to do to ensure that I can make an editable sidebar, so that widgets can be used on it?

  4. I’m working on a release of the plugin so everyone can see the code, as well as API documentation. It’s really not difficult.

    Here is a piece of advice though: make your sidebar one giant unordered list. Don’t use divs. sidebar.php should look like this (pardon the lazy brackets):

    [ul id=”sidebar”]
    [?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(1) ) : ?]
    {insert non-widget sidebar list items here}
    [?php endif; ?]

    Then this must go in functions.php:
    if ( function_exists(‘dynamic_sidebar’) ) :

    Building your sidebar any other way will force you to do more work to make it work. Creating multiple sidebars is easy, however. You’ll see it in the docs later this week. For a sample, switch to the WP-Andreas-09 theme.

Comments are closed.