March 17, 2009
How to widgetize a WordPress blog theme

Okay, if you’re new to WordPress, more than likely all of the themes you are looking at using are widgetized. For that special occasion that your WordPress blog theme isn’t widgetized, here’s a simple way of how to hack your theme, and with just a little bit of code, you can widgetize your theme.
Here’s what the official page from Automattic says:
Instead of register_sidebar() you should use register_sidebars(n) where n is the number of sidebars. Then place the appropriate number in the dynamic_sidebar() function, starting with 1. (There are several other ways to use these function. See the API). You can even give your sidebars names rather than numbers, which lets you maintain a different set of saved sidebars for each theme.
You edit this in the functions.php file. If you don’t have a functions.php file, then you probably don’t have a widgetized theme. Here’s an example of some code that you could put in your functions.php file:
<?php
if ( function_exists(’register_sidebar’) )
register_sidebar();
?>
Then, right beneath the <ul> tag in the sidebar.php file, add this little piece of code:
<?php if ( !function_exists(’dynamic_sidebar’)
|| !dynamic_sidebar() ) : ?>
Then, right above the closing </ul> tag, put this code:
<?php endif; ?>
Pretty simple huh? Now that old-school WordPress theme that you are using is completely widgetized and customizable!
Related posts:
- Display the Author Who Edited a Post Last
- Display Today’s Date on your Blog
- Automatically get tr.im urls for your blog posts
- How to Number Your Comments
- How to preset text in the WordPress post editor
Previous Post and Next Post

Trackbacks
- Daily Links | AndySowards.com :: Professional Web Design, Development, Programming, Hacks, Downloads, Math and being a Web 2.0 Hipster? 03-18-2009 at 8:06 pm
- You are now listed on FAQPAL 03-19-2009 at 10:05 am
- Top tutorials week ending 03/21/09 | FAQPAL Blog 03-21-2009 at 9:01 pm












