Birth of a Widget

March 21st, 2008

I decided it was time to try a new theme for my blog. Poking around in the WordPress admin screens, I spotted for the first time a message that my current theme wasn’t widget aware. This naturally sent me off on a hunt around the WordPress site to find out what a Widget is and why I should want one.

It turns out that widgets are a way the WordPress team have come up with to enable people to customise the sidebars on their blogs by simply dragging and dropping - no coding necessary. Sounded like a must have - so I followed the simple instructions and made my theme widget aware.

I had previously written a WordPress plug in to display a nested hierarchy of pages - the Fold Page Menus Plugin. This no longer worked, as the code that displayed the page menu was now a built-in WordPress widget. So, the obvious thing to do was to turn that into a widget - so please help yourself to the Folded Pages widget and use it instead of the built-in Pages widget.

If you’re thinking of writing your own widget, please feel free to use this as a template. It’s got all the basics, including a config screen. Note that it’s actually packaged as a plugin, so you need to activate it like any other plugin before use.