Adding Extra Sidebar to your Wordpress Theme
You like a Wordpress theme on the Internet but Oh!… What’s this?? The theme has only one sidebar! You need more than one and are on the verge of switching to some other theme with more sidebars. But wait!! Let me teach you how to add an extra sidebar or sidebars to your favorite theme. People who know PHP will find it easy to follow but even novices can easily do it using the code that I have provided in this tutorial. I am assuming that you already know HTML and a bit of CSS.
To begin the tutorial, extract your theme into a folder and open it to see all the files. If your theme has only one sidebar, then most probably you will NOT find a file called functions.php in your theme folder. In that case you will have to create this file yourself. Just open notepad or any other code editor to start a new file. Put this code into that file :-
<?php
if ( function_exists('register_sidebars') )
register_sidebars(2);
?>
Save the file as functions.php and put it in your theme folder. This piece of code actually tells Wordpress to register two sidebars for you (See register_sidebars(2) in the code). If your theme has more than one sidebar, you will find the functions.php file already present in your theme folder. You just have to edit the number to your requirement and save the file. You can increase this number if you want more sidebars and if your theme’s layout can accommodate it. Now, when you go to your Wordpress admin section and browse to the widgets under the menu item called presentation, you will see two sidebars listed there. You can drag your widget items into any of the sidebars.
Now comes the part where we actually build the sidebars. If your theme has only one sidebar, try to locate a file called sidebar.php in your theme folder. In this example, where we are trying to modify the theme for two sidebars, let’s rename sidebar.php to sidebar1.php and make a new blank file called sidebar2.php. Put this code into sidebar2.php and save the file :-
<div>
<ul>
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?>
<?php endif; ?>
</ul>
</div>
So, we have the two sidebars ready but they have not been placed in the index.php file yet. Both these sidebars need to be called from the index.php file in order to include them in your theme. Just open the index.php file from your theme folder and locate the code that calls your sidebar file (sidebar.php earlier). It should look something like :-
<?php include (TEMPLATEPATH . '/sidebar.php'); ?>
Edit this code and change the words sidebar.php to sidebar1.php.
This takes care of the first sidebar. Now take a look at the index.php file carefully and find a suitable place to insert the second sidebar. This might involve modifying your layout or adding new divs. Once you find a suitable place, place the following code there :-
<?php include (TEMPLATEPATH . '/sidebar2.php'); ?>
Save the index.php file and now preview your theme. You will see all the widgets that you placed in both your sidebars appearing on your website. If you have not placed any widgets yet, you will not see any change. There might be alignment errors but you will have to fix them yourself. You can add more sidebars in a similar way to your Wordpress theme. I hope this tutorial helps some of you.



































can we use software to add sidebar wp?
Currently I am learning how to setup a wordpress blog, its amazing how much resources there is on the web. Thank you for this information. I have Stumbled this page for others to find. Thank you.
A brilliant tutorial, mine didn’t work exactly as described, but worked perfectly. Took less than an hour to put in a second bar, and place it nicely.
Thanks very much.
n
srr wrong text index looks like this
hey i have other problem i cannot find this:
my index.php look like this
<h3 class=”entrytitle” id=”post-”> <a href=”" rel=”bookmark”>
Posted <?php
the_time(‘F j, Y ‘);
$comments_img_link= ”;
if (function_exists(‘enp_edit_link’)) { enp_edit_link(__(‘ Edit This’)); }
else { edit_post_link(__(‘Edit This’)); } ?>
<!–
–>
hey. added the sidebar. nice. but there is a problem. i have a plugin activated in one of my two sidebars: “recent entries” and after doin’ a search query, it all works fine, excepto for the “latest entris” widget… shows in the list all the pages in the site… not very useful, since i already have a list with the pages (menu list). what could be the problem??
oh, and it ony happens when i do the query.
thanks.
Nice tutorial, but this isn’t that helpful for those who are looking to add a sidebar for themes that have none defined already. Can somebody point me in the direction of a good one?
email – cyclosity (@) gmail.com
Great tutorial. This was exactly the how-to information I was looking for and you explained it perfectly. Now I can fix my themes!
HEY THE NEW SIDEBAR AUTOMATICALLY CODES WITH BULLETS. HOW DO I GET RID OF THAT? I’VE TRIED EVERY REMEDY AND NOTHING IS WORKING!