Widgeting Themes with Multiple SidebarsSaturday, January 31st, 2009 with 1 Comment »

Unfortunately, this theme (BloggingPro) was not widget enabled, so some work needs to be done. The Widgetizing Themes tutorial was useful for setting one sidebar, but in my case, there are multiple sidebars. Here is some code to make multiple sidebars widget ready…

First, this theme does not have a functions.php file for theme specific functions. Therefore, I uploaded wp-content/themes/[theme name]/functions.php. The file contains the following:

function.php

<?php
if ( function_exists('register_sidebar') ) {
  register_sidebar( array(
  'name' => 'sidebar_left',
  'before_widget' => '',
  'after_widget' => '',
  'before_title' => '<h2>',
  'after_title' => '</h2>') );
  register_sidebar( array(
  'name' => 'sidebar_right',
  'before_widget' => '',
  'after_widget' => '',
  'before_title' => '<h2>',
  'after_title' => '</h2>') );
}
?>

Next, we need to enable dynamic sidebars. Open wp-content/themes/[theme name]/sidebar.php.

We want to add dynamic sidebars for the div classes SRL and SRR. Different themes will use different names for sidebars div class names, so it may not look the exact same, but the concept is the same. After
<div class="SRL"> add:

 <?php if ( !function_exists('dynamic_sidebar')
        || !dynamic_sidebar('sidebar_left') ) : ?>

Right before the ending <div&gt for <div class="SRL"> add:

<?php endif; ?>

Similarly, do the same for the right side bar. After
<div class="SRR"> add:

 <?php if ( !function_exists('dynamic_sidebar')
        || !dynamic_sidebar('sidebar_right') ) : ?>

Right before the ending <div&gt for <div class="SRR"> add:

<?php endif; ?>

Now your theme is widgetized!

Get updates as often as we post! Subscribe to our full feed or comments feed.