colorpress - Premium WordPress Theme
$49.99

ColorPress is a theme that lets you play with color! Now, you will not be restricted to using a few color schemes provided by the developer. You have all the colors to apply to your theme! Just pick your color and magic happens. The theme comes with a configurable slideshow, 3 blog layouts, dropdown menus and a load of other options that will rock your socks!

Wix.com

Nov
23

Adding Extra Sidebar to your Wordpress Theme

Oh!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.

Working Hard!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.

Here you go!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.

DIGG this tutorial!

This post was viewed 89,978 times

» 231 people left comments { Collapse all | Expand all }

  1. 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,

    That’s a big BS…
    Your post title is misleading completely. You are just describing very superficially, how to add widgets to a second sidebarNOT how to add a second sidebar in the design/layout.
    So, basically, for those that have a one-sidebar theme – this “tutorial” is absolutely useless.

    Reply to this comment
  2. @JIM:-

    Let try this approach to some help. If after all steps are done, should Ibe able to use just the new sidebar2.php file in place of sidebar1.php and have it display where sidebar1.php did display

    JIM

    Reply to this comment
  3. @JIM:-

    ?php include (TEMPLATEPATH .’/sidebar1.php’); ?

    Reply to this comment
  4. I am struggling here. When I put this code in my Blog.php file the sidebar1 does display

    but if I change it to sidebar2, nothing displays????

    THOUGHTS PLEASE

    JIM

    Reply to this comment
  5. @JIM:-

    Jai, in the ‘open Air’ theme the Teplatepaths are in the Blog.php file. I did add both Templatepath statements to it.

    I think the no display is really the added CSS for the left new sidebar. If you look at my site, I adjusted the other columns to the right, but something in the new DIV is not right yet.

    THANKS

    Jim

    Reply to this comment
  6. @JIM:-

    this time it will work

    1?php include (TEMPLATEPATH . ‘/sidebar.php’); ?

    Reply to this comment
  7. @Jai:-

    Thanks Jai, yes I did. Funny thing is my index.php did not have the original sidebar statement in it that you talked about

    that was not in my index.php file

    Reply to this comment
  8. @JIM:- Did you actually include the sidebar in your code :-

    < ?php include (TEMPLATEPATH . '/sidebar2.php'); ?>

    Reply to this comment
  9. @JIM:-

    Jai, i know i am the last person to see and look at this tutorial, but I would really like to get it installed for ads on the left side.

    I spent last night adjusting my online site to make room on the left. That in itself for a non GURU took hours.

    After trying to get things to add the sidebar it just will not display for me. In the design-widgets drop down box, I do have sidebar 1 and sidebar 2. I added a calendar to sidebar 2 but no display.

    Any help greatly appreciated.

    JIM

    Reply to this comment
  10. Jai,

    Can this tutorial also put the new sidebar on the left. My site has 2 columns. One in center ( for post ) and a sidebar on the right.

    THANKS

    JIM

    Reply to this comment
« 2415 14 13 12 11 10 9 8 7 6 51 »

» Leave a Comment!

Search :
Browse :
Archive :

$$$ Make Money $$$

Become an Affiliate

Welcome to Blog Oh! Blog's affiliate program! I personally invite you to make money by selling all of Blog Oh! Blog's Premium themes.

You will get a whopping 25% share on each sale generated through your affiliate link.

All you need to do is sign up as Blog Oh! Blog's affiliate, choose a banner, paste it on your website or blog and wait for sales to happen. It's as simple as that!

All affiliates will be paid on 10th of every month. Your affiliate earning needs to be a minimum $50 to get paid for each month.

Here is the sign up link and here are some banners to get you started!