A Fully Widget-ized WordPress Theme

Updated August 3rd,2009 » So You Want A NextGen Gallery Slideshow as a Banner(!?!)

Learn how to add more sidebars to your theme and be able to use widgets in any part of your theme. Confused? Well, many plugins provide widgets and if you want to use them they have to go into the sidebar(s). But what do you do if you want to use a widget in a part of your theme that isn’t a sidebar?

I’m going to tell you how to make any part of your theme into a “sidebar”. So you can put widgets in it and be happy!

What is a WordPress sidebar? It contains PHP and HTML, right? Well then, a sidebar doesn’t have to be a long skinny rectangle on the side of your blog or website. It can be a banner with rotating images(or whatever you want) and that is what I am going to show you how to do in this post. You can use these steps and your own ingenuity to stick widgets from other plugins wherever you like. It’s not limited to nextGen Gallery slideshow widget. I’ve used this technique to add Random Quotes, the WP-E-Commerce Shoppingcart widget…etc. If it has a widget it can go anywhere. That is my point. Anyone who is very comfortable hacking their templates and themes can follow this post just fine.
Read on to follow the tutorial on adding more sidebars and getting the nextGen slideshow widget in the header/banner of your theme.

Standard code found in most functions.php to register a single sidebar.
(example one)
[php]<?php
if ( function_exists(‘register_sidebar’) )
register_sidebar(array(
‘before_widget’ => ‘<li>’,
‘after_widget’ => ‘</li>’,
‘before_title’ => ‘<h2 class="widgettitle">’,
‘after_title’ => ‘</h2>’,
));//ends this php statement
?>//closes php code[/php]

If your functions.php registers your sidebar this way:
[php]<?php
if ( function_exists(‘register_sidebar’) )
register_sidebar();
?>[/php]
Replace it with the code in example one. This is just easier and will not wreck your current sidebar set up.

One left out or misplaced curly bracket and your entire website will break so make copies and save them!

You must always copy all of your original theme’s files and save them so that in case something goes terribly wrong you can just delete the offending file(s) and re-upload the working ones.

Adding another sidebar to your theme (to use as a widget ready div)

After the last ));

and before the ?> in example one

Add This:

[php]if ( function_exists(‘register_sidebar’) )
register_sidebar(array(
‘name’ => ‘BannerDiv’,
‘before_widget’ => ”, // Removes <li>
‘after_widget’ => ”, // Removes </li>
‘before_title’ => ‘<h2 class="notitle">’,
‘after_title’ => ‘</h2>’,
));[/php]

Note that I have removed [html]<li> and </li>[/html] because my “widget ready div” isn’t going to be using lists.

Copy this code:
[php]
<div id="banner">
<?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(‘BannerDiv’) ) : else : ?>
<?php endif; ?>
</div>[/php]

Paste this into a plain text file and save it as slideshow.php and upload it to your theme folder.Then upload the new functions.php. It’s a good idea to do it in this order. In your theme’s style.css add the line .notitle{display:none} If you do not want your new widget ready div to have a title.

Go to for more information and examples.