Mostly about my amusement

Widgetized my theme

In preparation of installing WordPress 2.5 I finally widgetized my theme. I’m using an old 2.0 version of FastTrack. Widgets have been around for a long time so as I play with 2.5 I figured I’d come up to speed with a 2.0 feature.

I had a bunch of nested if..thens so that the home page would show one sidebar and single posts and pages would show another. I had cleaned up the theme so I now had separated the two sidebars in the file.

In my theme’s function.php I added the following lines:

if ( function_exists(’register_sidebar’) )
register_sidebars(2,array(
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ‘<h2>’,
‘after_title’ => ‘</h2>’,
));

This let me define 2 sidebars, one for the home page and one for not the home page.

In my sidebar.php I placed

php code for the is_home() sidebar

<?php endif; ?>

<?php } else { ?>

<?php if ( !function_exists(’dynamic_sidebar’) || !dynamic_sidebar(2) ) : ?>

php code for the all other pages sidebar

<?php endif; ?>

<?php }?>

This let me have a default for each sidebar. That’s where I ran into a snag. I want to re-use the same widgets in both sidebars. The widgets won’t let me use them twice. I wanted to use the meta widget on the home page as well as on the single posts.

If I want I can define additional duplicate widgets but that’s a pain. I’m playing with the idea of defining a third dynamic sidebar and display that on the bottom of each sidebar.

I’ll keep playing with it to find a solution I like.