How to Add Extra Sidebar to your WordPress Theme

Normally the wordpress theme has only one sidebar! But if you need more than one and want to switch some other theme with more sidebars. Then this tutorial is helpful for you 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 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 find a file called functions.php in your theme folder. Link


if (function_exists(‘register_sidebars’))



Now change the code like


if (function_exists(‘register_sidebars’))



Now make a new blank file called sidebar2.php. Put this code into sidebar2.php and save the file :-



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

<?php endif;?>



So, now our 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 get_sidebar();?>

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

<?php get_sidebar2();?>

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. You can add more sidebars in a similar way to your WordPress theme. I hope this tutorial helps some of you.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: