Monday, December 01, 2008 |
||
Widget Compatible Themes « WordPress Support
SridhaReena: CMS, Scripts, Software, Technology tidbits, WordPress, and everything Internet
Ruidoz » Blog Archive » widgetizar
Support WordPress France / Crer ses propres widgets avec Theme Widgets
Support WordPress Francophone / [Rsolu] Crer ses propres widgets avec Theme Widgets
Standing Tall » WordPressウィジェット一覧
So you’ve just completed your upgrade to WordPress 2.x. You’ve installed the latest and greatest versions of your favorite plugins. You’ve lovingly tweaked your favorite theme to within an inch of its life. All is well with the world.
Then the WordPress development team comes along and introduces the brand new WordPress Widgets: slick chunks o’ code that make it easy to modify your WordPress-powered site’s sidebar from a simple drag-and-drop menu. Overnight there’s a new widget blog, a flurry of rejiggered themes, and the utterly grotesque new jargon “to widgetize.”
The good news? Customizing a third-party WordPress theme is much, much easier for end-users.
The bad news? While coding up a widget isn’t rocket science, it’s beyond the PHP skill level of most theme designers. (Those who want end-users customizing their themes, that is.)
As a result, there’s an awful lot of perfectly good code suddenly consigned to the dustbin. On the flip side, there’s been a ton of energy devoted to creating widgets that are essentially wrappers for existing plugins.
Wouldn’t it be better if making widgets were as simple as making theme template files? Well, now it can be that simple thanks to modifications I made to a sample widget by plugin writer Kaf Oseo.
Here’s how it works:
Download and install the WordPress Widgets plugin.
Download and install my Theme Widgets plugin.
If you are not using the WordPress default theme (Kubrick) or a theme that has already been updated to be widget-friendly, follow the instructions for enabling the dynamic sidebar.
For each widget you want to offer, create a file with the appropriate code in your theme folder using a name that begins with widget- or widget_.
For example, try creating a file named widget-example.php in your theme file with the following contents:
<?php
/*
Widget Name: Theme Widgets Example
*/
print("<p>This is an example of the Theme Widgets plugin.</p>");
?>
Go to the “Sidebar Widgets” item in the presentation menu. At the bottom of the page you should have a new dialog box that lets you set the number of theme widgets:

Then find "Theme Widget 1" in the “Available Widgets” box above and click on the widget options icon (where the blue arrow is pointing below).
![]()
You should see a dialog box like this one:

Just click on the radio button for the theme widget you want — in this case you’ll obviously just have the one widget-example.php to choose from — and fill in the optional title and text fields if you’d like.
![]()
If all goes well, the next time you visit your site you should see “This is an example of the Theme Widgets plugin.” in your new sidebar. You’re now in business!
So there it is: ten simple steps to theme widget happiness. It’s so easy, it’s Automaggic!