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

Leave a Comments | Trackback | RSS 2.0

  1. 1. milo | December 25, 2006 #

    Good to know, is it a must do?

  1. 2. hso | December 25, 2006 #

    @ Milo

    Since you are designer, yes! This will be standard on all next-gen themes.

  1. 3. sofyst | December 25, 2006 #

    I guess the obvious question is, what if the sidebar is not as above? I am using your Easy White theme.

  1. 4. hso | December 26, 2006 #

    @ Sofyst

    The note was mostly directed towards designers, but yes, any theme can be moded to make it widget ready. If the sidebar markup is not as mentioned here, then you can either change the markup (most all my themes can be modified to this markup without issues!), just make sure that the styling does not throw the theme off!

    As for Easy White theme, on close examination you will notice that the markup is as described above! 

  1. 5. sofyst | December 26, 2006 #

    Well I thought so as well, but when I placed the code within the sidebar, it showed up on my site (you could see the code from the frontpage). It didn’t screw anything up, as far as messing up alignment or anything, but it did show from the front…perhaps this is why I am not a designer.

  1. 6. sofyst | December 26, 2006 #

    Ok, call me a newb, its aight. I figured it out. No spaces allowed. ;)

  1. 7. hso | December 26, 2006 #

    @ sofyst

    I included the spaces to display the codes without execute it! Should have mentioned, sorry.

  1. 8. headsetoptions » Blog Archive » Tree (V2) Redux With Widgets! | January 5, 2007 #

    [...] I reworked the theme eliminating all the original files and starting with just the stylesheet. This theme is “widgets” ready and no longer uses the themetoolkit file! [...]

  1. 9. chris | July 2, 2007 #

    Hi,
    I’m trying to install “earthy”, which includes “sidebar widgets”. Anyhoops, I go to the plugins panel, and try to activate sidebar widgets, and get this error message, “Plugin could not be activated because it triggered a fatal error.”. Anyone have any ideas?
    Thanx in advance
    Chris

  1. 10. hso | July 3, 2007 #

    @ Chris

    Check to see if there are other plugins that are active which might affect the Widgets! Check for plugins compatibility. Deactivate all plugins and activate only the widgets one, if it works, then try turing the rest on to find which (if any) is causing the issue.

  1. 11. gun | August 15, 2007 #

    hso, i use tree2 themes, but i cant activated widgets in sidebar, same with chris. “Plugin could not be activated because it triggered a fatal error.”

    I use wordpress 2.2.2, iknow that version dony need widgets plugin but i can activated widgets plugin.

    thx

  1. 12. hso | August 16, 2007 #

    @ Gun

    Download the latest version that is widget ready from here.

  1. 13. gun | August 17, 2007 #

    i cant hso..:(

  1. 14. hso | August 19, 2007 #

    @ Gun

    Can you tell me you site URL so I can see what version you are using. The err you are mentioning is very typical of version 01.

Have Your Say »

(Required- use your name, not keywords)

(Required- will not be published)

(Optional)

Use SimpleCode while pasting codes.