24.Dec.2006 at 5:28 pm | Sunny
Why The “Widget” Fuss?
If you're new here, you may want to subscribe to our RSS feed. Thanks for visiting!
“Widgets” are used to personalize your WordPress site without knowing HTML, it is a neat plugin created by Matt et. al. and is fast becoming a “must have” for new theme designers to be able to sell (or in this case give away for free!)
Widgetizing a theme is rather simple, just as long as your sidebar markup is as below:
< ul id="sidebar" >
< li id="sponsor" >
< h2 >Sponsor< /h2 >
< ul >
< li >< a href=http://www.getm.org >Example< /a >< /li >
< /ul >
< /li >
< /ul >
That is, the entire sidebar is an unordered list and the titles are in < h2 > tags!
All you then need to do is, add two lines of code:
< ?php if ( !function_exists('dynamic_sidebar')
|| !dynamic_sidebar() ) : ?>
and
< ? php endif; ? >
as shown below:
< ul id="sidebar" >
< ?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> < li id="sponsor" >
< h2 >Sponsor< /h2 >
< ul>
< li >< a href=http://www.getm.org >Example< /a >< /li >
< /ul >
< /li >
< ? php endif; ? >
< /ul >
Of course we are assuming you have only one sidebar, if you have two, then each column will have a code such as:
< ? php /* WordPress Widget Support */ if (function_exists('dynamic_sidebar') and dynamic_sidebar(1)) { } else { ? >
closing with
< ?php } ? >
That’s it





1. milo | December 25, 2006 #
Good to know, is it a must do?