Widgetizing Your Blog
June 15th, 2007 · by David Bradley
If you have already upgraded to Wordpress 2.2, then this post is not for you. But, if you are languishing on an earlier installation and running a theme that does not support widgets, then you may like to check out how to get widgetized. But, first what are widgets? Well, they’re little snippets of code that sit in their own boxes within your sidebar and can be reordered with a simple drag and drop. So, your search box is at the bottom and your Feedburner count at the top but you want them the other way around? It’s a lot of cutting and pasting with the standard sidebar in Theme Editor, but if your blog is widgetized all you do is drag the search widget to the top of the stack and the Feedburner block to the bottom. And save the new settings.
The Automattic site has the full skinny on widgetizing your site and provides you with the necessary downloads, so I am not going to repeat their wise words here. But, one aspect of widgetizing the Sciencebase site earlier this year, prior to the release of version 2.2, was that I simply could not eradicate an orphaned bullet point that was appearing at the top of the sidebar with no entry to which is was associated. I messed around with the li and ul tags in the widgets themselves, played with the css in the widgets.php (adding the list-style-type: none; tag to all and sundry to try and delete the little dot). Actually, I grew quite fond of the little critter in the end, but knew that most visitors would prefer not to see the bullet, it was far too distracting.
Finally, after searching the web and reading the manual a dozen times or more I went back to the Automattic site, where it finally dawned on me that a hack they mentioned in regard to formating non-standard sidebars ready to be widgetized might actually work for me too.
To make widgets work in versions of Wordpress pre-2.2 you have to have a file called functions.php in your theme’s folder. This file holds nothing but a conditional tag to render the widgetized sidebar as appropriate, but you can add an extra argument or two to make the widget plugin ignore some of the formating in its inbuilt CSS:
<?php
if ( function_exists(’register_sidebar’) )
register_sidebar(array(
‘before_widget’ => ”, // Removes the list tag
‘after_widget’ => ”, // Removes removes the end list entry tag
‘before_title’ => ”, // Removes the head tag
‘after_title’ => ”, // Removes the end head tag
));
?>
Once I’d added this code, fixing the angle brackets to be the actual html enclosures, and reloaded the Sciencebase site up it popped, sans bullet. I will miss the little critter though.

















2 responses so far ↓
Eliena // Jun 17, 2007 at 2:35 pm
can i implement this code on my blog page ?
David Bradley // Jun 17, 2007 at 7:02 pm
Sorry Eliena, but I don’t understand why you would want to do that in the first place. Blogspot is its own system, presumably you have not above blog folders anyway, so what would you be implementing, regardless of the fact the hack is for Wordpress?
db
Leave a Comment