Adding a second sidebar

This is surprisingly easy once you get your head around the widget facility in Wordpress.

Ultimately, we’ll be finishing up with one left sidebar and probably two on the right but the two rightmost ones will, for the moment, be identical so all you need to do to add an extra one is to edit the functions.php file and replace the first section with the following:

if ( function_exists(’register_sidebar’) )

register_sidebar(array(

‘name’=>’Sidebar 1′,

‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’,

‘after_widget’ => ‘</li>’,

‘before_title’ => ‘<h2 class=”widgettitle”>’,

‘after_title’ => ‘</h2>’,

));

register_sidebar(array(

‘name’=>’Sidebar 2′,

‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’,

‘after_widget’ => ‘</li>’,

‘before_title’ => ‘<h2 class=”widgettitle”>’,

‘after_title’ => ‘</h2>’,

));

Then create a very short sidebar2.php:

<div id=”sidebar”>

<ul>

<?php if ( function_exists(’dynamic_sidebar’) && dynamic_sidebar(’Sidebar 2′) ) : else : ?>

<?php endif; ?>

</ul>

</div>

And finally, edit index.php and single.php to add:

<?php include(”sidebar2.php”); ?>

Just after where it has <?php get_sidebar(); ?> (towards the end of the file).

Then you can go to the presentation section of the theme and add stuff into the second sidebar.

In practice, I’ve done a little more than that as I want to retain the fluid width which means changing a few fixed widths for the sidebars to percentage widths.

One other side-effect is that the second sidebar runs straight into the skirt on the original image and is unreadable, hence the change of image at this point. As you can see, this image isn’t ideal either so I’ve had to change the font to bold ’til I get a more suitable image.

Copyright © 2008 by SevaTeem Ltd. All rights reserved.

Leave a Reply