Adding Extra Sidebar to your WordPress Theme

Published On November 23, 2007
404 Comments Leave a Comment

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 :-

  <ul>
    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?>
    <li>
      <h2>
        <?php _e('Categories'); ?>
      </h2>
      <ul>
        <?php wp_list_cats('sort_column=name&hierarchical=0'); ?>
      </ul>
    </li>
    <li>
      <h2>
        <?php _e('Archives'); ?>
      </h2>
      <ul>
        <?php wp_get_archives('type=monthly'); ?>
      </ul>
    </li>
    <?php endif; ?>
  </ul>

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!

404 replies on “Adding Extra Sidebar to your WordPress Theme”

What’s Happening i am new to this, I stumbled upon this I have discovered It positively helpful and it has helped me out loads.
I’m hoping to give a contribution & aid different
users like its aided me. Great job.

I have noticed you don’t monetize your site, don’t waste your traffic, you can earn extra cash every month.
You can use the best adsense alternative for any type
of website (they approve all websites), for more details simply search in gooogle: boorfe’s tips monetize your website

Withh havin so much content and articles do you ever run into any problems of plagorism
or copyright infringement?My site has a loot of unique content I’ve either created myself or outsourced but it looks like
a lot of it is popping it up all over the internet without my authorization. Do you know any methods tto help protect agains content from being ripped off?
I’d truly appreciate it.

It is very astonishing to know that when for the
very first time, this website was introduced in the website
design and development world it got appreciation from the esteemed web business magnates.
The best solution could require website re-organization and additional brainstorming.

No matter how latest trend you have used to present your
website, it remains as a waste if it is not
meaningful for the user.

Greetings from Los angeles! I’m bored to tears at work so I decided to check out your blog on my iphone during lunch break.

I really like the information you present here and can’t wait to
take a look when I get home. I’m shocked at how quick your blog loaded on my
cell phone .. I’m not even using WIFI, just 3G ..

Anyhow, amazing site!

Think that a stairs have mislaid their former glory. I hope the answers and questions is
going to be necessary to you. This means that you can invest some time and spread the
project out over months and years as an alternative to attempting to cram everything in and find
it over with.

Magnificent items from you, man. I’ve be mindful your stuff previous to and you are just too great.
I actually like what you’ve bought here, certainly like what you’re saying and the best way by which
you are saying it. You are making it enjoyable and you still care for
to stay it sensible. I can not wait to learn much more from you.
That is actually a terrific site.

Thanks for this great work. I appreciate it. I have been searching for this for a long time.
Proffesional and useful. Very nice job and good work. I am a dentist and this is a good stuff to read for me and for anyone who has the interest in this kind of knowledge and scince.
I have learned very much and have got useful knowledge, that I can use in my life.
I am going to be a daily visitor to your site of this website. I just wanted to say that I appreciate your blog and am looking forward for more to come (I don’t know how often you are used to write and how often you post).
I Thank you for spending the time to discuss this, and giving us the opportunity to learn. I feel strongly on this and love reading ekstra about the subject. I hope that there are others who share the same view as me.
I am definatly coming back dayly to see more and to learn more and to know more.
I am happy for being a part of this wonderful blog.
Keep up the good work and best regards and best wishes.

Hey there would you mind letting me know which web host you’re utilizing?
I’ve loaded your blog in 3 completely different internet
browsers and I must say this blog loads a lot quicker then most.
Can you recommend a good hosting provider at a reasonable price?
Thanks a lot, I appreciate it!

Hi there, I think your website may be having browser compatibility issues.

Whenever I take a look at your web site in Safari, it looks fine however when opening in I.E., it’s got some overlapping issues.

I just wanted to give you a quick heads up! Besides that,
wonderful blog!

I’ve been exploring for a bit for any high quality articles
or weblog posts on this kind of area . Exploring in Yahoo
I finally stumbled upon this site. Reading this info So i am happy
to show that I’ve an incredibly just right uncanny feeling I discovered exactly what I needed.
I most indubitably will make certain to don?t overlook this website and give it a glance regularly.

I read a lot of interesting content here. Probably you spend a lot of time writing, i know how to save
you a lot of work, there is an online tool that creates
readable, SEO friendly posts in seconds, just type in google – laranitas free content source

This design is steller! You definitely know how to keep
a reader entertained. Between your wit and your videos, I was almost moved to start my own blog
(well, almost…HaHa!) Wonderful job. I really enjoyed what you had to say, and more than that, how you presented it.
Too cool!

Hey and first off thanks for the post.
Is there a way to register which sidebar is which?

So we can use “get_sidebar” instead of “include”.

Like adding the sidebar templatepath somewhere else, like maybe functions.php and then using get_sidebar (1) or get_sidebar (2)

You actually make it seem really easy together with your presentation but I find this matter to be actually
something which I believe I would by no means understand.
It seems too complicated and very wide for me.
I’m looking ahead on your next submit, I’ll attempt to get the hold of it!

fantastic put up, very informative. I’m wondering why the other specialists of this sector don’t notice this. You should proceed your writing. I’m sure, you’ve a huge readers’ base already!

Greetings from Florida! I’m bored to death at work so I decided to check out your site on my iphone during lunch break. I love the knowledge you provide here and can’t wait
to take a look when I get home. I’m surprised at how fast your blog loaded on my mobile .. I’m not even using WIFI, just
3G .. Anyhow, good site!

The first part of the tutorial is great, but in the parts where you say “put this code in there” there is no code showing.. I’m not sure why! 🙁 This seems like a great tutorial and I would love to finish!

This keeps happening!
Parse error: syntax error, unexpected T_IF, expecting ‘)’ in /home/wjournal/public_html/wp-content/themes/lehigh/functions.php on line 387

I want to change the layout of my homepage columns. Do I do this is the home.php file? The theme I’m using is from StudioPress the Corporate theme, it doesn’t have an option of the layout i want for the homepage. I want a 2/3 column at the top lest, another 2/3 column under that to the left, to the right I want a 1/3 column that’s height is the total of the two columns to the left, then I want a footer colunm under all this the entire width of the page. I don’t know PHP.

Can’t see the codes

Can you please copy the codes in a comment? I can’t see the codes as the blue boxes appears to be empty. I’m following the part where I just renamed the sidebar.php file.

Thanks

Hi,

The theme I am using currently has a sidebar on the left, so there is a functions.php as you mention. However the code in there is a bit more… “complicated” so I don’t know what to change or insert. This is the code:

‘,
‘after_widget’ => ‘

‘,
‘before_title’ => ”,
‘after_title’ => ”,
));
?>

So what do I need to insert in this case? Also, like other said, can you update your post because the code doesn’t show in the boxes?

When you look in the source code of the page you can find the code. A bit more complicated, but it is there.
I could not see the code either in explorer, safari, firefox or google chrome.

Hi there, all your code comments are missing apart from the very first one and the one’s given in the comments. I have tried to use this tutorial in firefox 8 as well as chrome in Ubuntu and now the same thing is happening in firefox 8 and chrome in windows 7.

This tutorial is so useful, what I have done so far works great.
Unfortunately most of the code examples in the blue boxes are missing. Mac with Firefox 8. Can’t see it with Safari either. Please help! This is such a great tutorial otherwise. Thanks.

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:

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 :-

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 :-

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.

I can’t see the code in the blue box-outs either! Am running firefox 8 in Ubuntu 11.10 If someone can help it would be great because right now, I really, really need this tutorial! Thanks!

hello! my problem from the start is how to open and edit the php file, as i already have one sidebar + post area. i need two sidebars for sponsors! one other thing, assuming that i do all this, then i have to upload the theme again, right? for whom has changed all the editor file, that is not too easy… can you please give me some advice here? thank you!

Hi..

Nice tutorial…but I have a question: what if I want to create a “sidebar” in the header? I wanna put a widget there but I can’t. Could you help me please?

I’m trying to do that with a RTL custom template but for some reason I cannot manage the second sidebar CSS (on page). Can somebody tell me why Classes or ID’s aren’t working?
Anyway, Thanks for telling us about this modification.

I am wondering what widget you used to have the double column sidebar for the advertisement section at the top right of your blog? Thanks In advance!

After study a few of the blog posts in your web site now, and I truly like your means of blogging. I bookmarked it to my bookmark website checklist and will likely be checking back soon. Pls try my web page as well and let me know what you think.

And while they acknowledge that this is causing harm to their brand they still aren’t answering any direct questions. As I mentioned in the Money Woes post there simply isn’t a legal reason for this. And I think Full Tilt has proven how BS this excuse is with their response to the Ivey lawsuit (also mentioned in the Money Woes post).

Johannes Irfan Reply

Greetings from Indonesia.
I am looking for this for months, and now i find the way from you. thank ‘s alot.
To remake theme is a passion.

This method works! takes a while to get it working, had to do a google search and bumped into the wordpress codex, which states the commands here.

I think this method works most of the time when you are editing a theme that doesn’t have many theme files.

Thanks

Cool. Thanks for this! I am trying to add items to my blog sidebar only. Right now, there is one sidebar in the theme and when I add things to it, it adds them to static pages as well as the blog. How can I add items to the blog sidebar only? Thanks!

Nice information .Actually, I use twenty theme and was thinking to have more sidebars in my theme . I was searching in the net to get the proper help . But I was unable to get the proper info until I visited your Blog. I should thank you for the information you have placed here .

Thanks so much!!! This really helped me out a lot. I built my wordpress theme from scratch, but I used a single sidebar and was unaware of how to place two of them. Thanks again so much!

Yes! You took all the coding-shmoding mumbo jumbo and boiled it down perfectly. Now the only thing I can’t figure out is formatting. My sidebar appears on my page, but below or above the text of my page (stacked). How do I get it to function like that nice little sidebar it is and default left of the page content?

BEST TUTORIAL EVER, thank you SO MUCH!!! I love the mimbo theme, but I was so close to swapping because of the lacking left sidebard. You are amazing for posting this tutorial! <3

Hey, this is a great solution and I almost have it working. I’ve successfully added a 2nd sidebar to my functions.php but I cannot find a good place to put the 2nd sidebar in index/header/footer.php. Nothing seems to position the sidebar correctly. Can anyone help?

I also have the problem that there is nothing in index.php that refers to the sidebar. I’m using the Minima Black theme, with a right sidebar. If I put the code in index.php, the new sidebar just gets in the main column… after or before, it depends on where I put it…

Tried fixing it in sytle.css, but with no luck…

Miguel, try looking in the “header.php” and “footer.php” files. Sometimes it’s easier to include something on every page if it’s in the header or footer… It’ll most likely be in the header.

Miguel, try looking in the “header.php” and “footer.php” files. Sometimes it’s easier to include something on every page if it’s in the header or footer… It’ll most likely be in the header.

(My new keyboard seems to disagree with me typing, so I’m posting this again to fix the mess-ups, but I don’t know if I can delete the old one)

Hi there! Might you be able to help me with this? The theme I am using has only a left sidebar. I would like to change it to a right sidebar. What code do I change?

Thank you in advance!

Ginger

I followed all your steps but I must be missing something?? I’m adding a sidebar to a Theme that has only Footer Widget/sidebar areas….I was able to add a New “primary” and its in the Appearance area within Widgets…but when I activate a widget for that area….nothing shows up?? Any ideas would be much appreciated. Thanks, Rick

thank you sooooo much! This worked! I have been trying to follow someone else’s instructions for 3 hours now to no avail. I just found yours et voila! it worked! thank you!

Wow, wanted to create an “include” file so the horizontal navigation bar could be in it’s own file as WELL as have a sidebar…and this tutorial worked first time, within minutes of reading it…thanks for this very helpful article!

Just getting started designing custom themes and this tut helped immensely. Hopefully I will write something like this to help someone newer than me. Perfect. Thanks.

I’m converting a hand-coded site to WP using the Limauorange theme,which I really like.

I’m working to add a third widget column and have a questioin about the instructions in this post.

From what I can see, there is no place in index.php to add the TEMPLATEPATH . ‘/sidebar2.php’); ?> statement. I understand changing the sidebar(2) to sidebar(3) in functions.php, adding a new sidebar name in sidebar.php and creating a new sidebar file like sidebar3.php.

But there is no mention that I can find of sidebars in index.php.

What am I missing?

Thanks,

Barry

I’m using the WP Quickpic theme… LOVE IT, but i wish i could use the two gray empty spaces on the right and left side as sidebars. The sidebars in my widget area are registering at the bottom (I’d like to keep those as well…) Anybody know how I can do this? Please help…

Thanks! This was so helpful! I spent over an hour banging my head against the wall trying to figure out why my child theme wasn’t displaying two sidebars, then found your tutorial and had it working in <10 minutes.

What a great tutorial! I can see sidebar 2 in widgets 😀
My only, very special problem is that neither index.php or the other files (I have checked them all) have a line called sidebar.php which I think is very odd. Because I have a file called sidebar.php, so it has to be here somewhere…. I think that the “maker” has used the word widgets instead of sidebar, although I have a sidebar.php
I am using Comet by frostpress.
Is there any way you can answer to this question? 🙂

thank you for this tutorial
i was really looking for this since long. i found this theme creation tutorial in wpdesigner.com but found nowhere a way how to create multiple sidebars. now this page completes most of my querries. i am gonna try this out and get back to you later on this. thanks again

This is great, but not taking me all the way to where I need to be. Could you possibly advise?
I need to assign specific sidebars to specific pages. I would like to create more sidebars with this tutorial, and then reference them in certain templates I am creating for certain pages. So far I think I am on the right track. But it hasnt worked properly yet. I am wondering if I need to make any changes to my style.css file or not. Any help would be great.

”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));

function kubrick_head() {
$head = “\n<!–";

the post got cut off, I'll try posting lines 1 through 11 one more time.

theme: blue-diffusion has a functions.php file included I tried:

replacing that file w/a new functions.php including the code suggested file here. Failed.
altered the original code in functions.php to be identical to the suggested code here. Failed.

this is what the beginning of the code of the original functions.php file looks like, from lines 1-11:

”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));

function kubrick_head() {
$head = “\n<!–";

You said, "If your theme has only one sidebar, then most probably you will NOT find a file called functions.php in your theme folder." Yet, my theme has only one sidebar and a functions.php file.

Would Gladly and Highly appreciate anyones help.

Valerie Reply

I was wondering if you had a quick fix for changing the width of the sidebar?
In my css there is no #siderbar stuff to change the width.
Great post!
Thanks!

I have a wp blog and we have two sidebars which is ok, but …
the far right sidebar is ok but the middle sidebar which is thin.

Both sidebars stay the same for all pages but the home page, what I would like is that on some pages the sidebar is different than on other pages. As an example we have a page called coaching, well on that page, we want to sidebar to list testimonials of coaching students, and on the page that is speaking we want the sidebar to have testimonials of speaking clients.

Is this possible?

I have a dynamic Sidebar Left and Right, I disabled the sidebar right so that I could have more “content” space for my home page, however my problem is that when I add a widget to the left sidebar No links will show up..in other words you can see the ad or button but the link within the widget will not work. I’m using what they call a “Simple Image Link” and it works until I get to the 3 or 4th spot in the sidebar. Its almost as if the original “pages” and wp page list is still there even though I disabled it…however maybe the way I disabled it has effected that “area” so even if I had a widget in that first position it just won’t work?? I simply deleted the h3 pages and wp list pages?? Maybe that’s where I made the mistake??

John Reply

Unfortunately you assume a novice knows how to “extract your theme into a folder ”

and then you are unclear -“open notepad or any other code editor” – does this mean a word processor or a special html code editing program?

I know you know but if this is tutorial for people who don’t know then I’d suggest every step needs to explained.

BP Reply

Understandable, but “extracting” is to the point where if they explained even that, these tutorials would be useless to most people.

You can easily find instructions for “extracting” all over the web. It would be really unhelpful to have to explain that over and over in tutorials. I recommend you check out the basics tutorials of WordPress before trying to do custom things if you are having trouble with these concepts.

it wouldn’t take long and you’d be up to speed!

Thank you very much for your tip. I didn’t think that making a separate side-bar was that easy. I was able to make a totally separate sidebar for my blog and a sidebar for my other blog pages. Thank you very much!

First of all, fantastic theme! Very elegant and a pleasure to work with. However, once I added my 4 125×125 ads, they appear to push up against the header. Any solution for this?

Hi 🙂 thanks for this

im having some trouble tho, im using the theme stripey and when i get to the step where i have to find index.php and look for the code calling the sidebar, it doesnt have this code in there

Hello,

I’ve defined 2 sidebars, in the way you mentioned in the tutorial. I’m using the 2 column WordPress theme Fallseason from the WordPress Theme Park of Sadish. A very nice theme.

Sidebar 2 I’ve used for the index homepage.
And sidebar 1, the original one for the rest of the pages.

But now I can’t add any new activated widget to sidebar 1. Sidebar 2 no problem. But sidebar 1 gives an internal error as follows:

*Internal Server Error
*The server encountered an internal error or misconfiguration and was unable to complete your *request.
*Please contact the server administrator, support@one.com and inform them of the time the error *occurred, and anything you might have done that may have caused the error.

*More information about this error may be available in the server error log.

It’s a database access error, I think. How to solve this problem, so that I will be able to add a new activated widget in Sidebar1?

Thanksss, Lydia

p.s I like this 2sidebar solution a lot. But it does not really look like 2 sidebars. Also it’s only possible to add a widgets once to a sidebar.. it’s not possible to add a widget to both sidebars.

@remix:-
You could try:

if ( function_exists('register_sidebars') )
register_sidebars(2, array(
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));
?>

Seems to work for me;)

I’m having some more issues here. The article is great, but I think I am missing something. In index.php, there isn’t any code that calls my sidebar (i.e.). The original sidebar still displays but there is no code. So I am having trouble figuring out where to place the code to call sidebar2.php so that it will align with my original sidebar. Please help!

Whenever I make an edit to my function.php file, it brings back a syntax error. Even when I erase the error and refresh, the syntax never leaves. I’m forced to re-upload the default wordpress function.php file.

What am I doing wrong?

Ok….did everything and was great EXCEPT I want the extra sidebar on the opposite side.

Your instructions –

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 :-

My problem is the last thing before the end of the page code is “get sidebar”. If I add the second sidebar there, then there are 2 on one side.

Can you help me set it so there are sidebars on BOTH sides?

Thanks for this quick reference. I added a sidebar to a theme I’m hacking for someone. It was a bit too simple, so I wanted to add a sidebar the “proper” way 😉

Thanks again

I’m still lost on the first step with the functions.php file. My theme has one, but I don’t know where to edit in the number to my requirement?

My code says:

‘leftsidebar’,
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));

}
?>

Can anyone please help me on this one? I’m trying to learn this from scratch. I’m taking over a site someone else started. Thanks in advance.

brenda Reply

Thx for the tutorial. I was trying to add a column for advertising and couldn’t figure out why my ads weren’t showing. After reading the tutorial, I realized that I forgot to place my “call code” in the index file.

Great site – keep up the helpful and informative work~!

Wouter Reply

Hi!

How do i get the USER to choose the sidebar, instead of the template ( with if, else statements)
So I would like an extra option to the page-admin with a dropdown of available sidebars.

Any suggestions where to start?

Thanks!
Wouter

Ajay Reply

hi there thanks for this! I’m working with a theme which is perfect for my needs but it has no sidebar! I can’t look for another one just because of this. Is there a way to add one?

Hi there,

Your quick-fix tut saved my skin when developing for my first client. Thanks so much for providing this here. I’ve bookmarked your article and will trackback when I get a chance.

hello! thanks for the very easy understandable explanation.
i coul add another sidebar, but now i’ve got bullet poist in my layout. i searched for list-style-types in my css, or for “square”, but could find anything, that could remove them.
help me please…

thx, Bull

Is there a simple fix for calling different footers for different pages.

ie. If i want the ‘standard’ footer on the posts but a different one on the pages etc.

Thank you SO much for this small but ever so helpful tutorial. I have been trying to get a second sidebar to show up so I can use widgets in it but wasn’t getting very far until I came across your post. Following your instructions here, I was able to get both sidebars registered and working without any problem. *grin*

Really useful post and easy to follow.

I thought I would share the few problems I encountered along the way:

1) In the functions.php file, I had a register_sidebar() function – you need to make sure you change this to register_sidebars(n) (where n is the number of sidebars) as register_sidebar seems to only register the one!
2) In your index.php file, rather than seeing you might only see get_sidebar() (which is equivalent to
3) you may also need to make changes to other template files (e.g. page.php, single.php, 404.php) as well as index.php (depending on theme).

My functions.php file shows:

if ( function_exists(‘register_sidebar’) )
register_sidebar(array(
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
))

I have nowhere to change the number of register_sidebar. How do I add a sidebar to the above code?

Hey, How can you modify the above code so that each sidebar has it’s own name when you are in the widget screen?

for example I don’t want ‘sidebar 1’, ‘sidebar 2’, ‘sidebar 3’, etc.

I want menu 1, footwear 2, store 3, etc… the numbers coming from the %d code.

Anyone know?

Great tutorial! But I’m at a loss…
My theme only has one sidebar, but has a functions.php file. This is its contents:

”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));
?>

Calendar

What do I need to do to add a second sidebar?

I have tried the above and this is what i get when i try to activate a widget.

Warning: Cannot modify header information – headers already sent by (output started at /home/telesco/public_html/wp-content/themes/e-wallet/functions.php:8) in /home/telesco/public_html/wp-includes/pluggable.php on line 850

Please help…

canute Reply

my theme has already the function.php
i open it and show this

if ( function_exists(‘register_sidebar’) ) {
register_sidebar(array(
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));
}

the problem is
i cant add another one
or just cant figure out
if anybody knows how i can fix it
i apreciate it

@Dan:-
Hello,
I do not see a reply to this particular question. I have the same problem. My index.php does not contain include lines instead it contains a call get_sidebar(). I do not know how to change this to get a second sidebar. I have made the changes to functions.php and made the files sidebar1.php and sidebar2.php so I do see it in worpress editor but it does not appear on page as I cannot firgure out what to use instead of get_sidebar. Would really appreciate the help.

@Jai
I sent you an email too..but for others I have seen several questions of how to get the sidebar on the far right side, if you already have the original sidebar on the left. I can get the new sidebar to appear but it doesnt seem to matter where I put the code in the index.php file it still ends up either below the posts or on top of the posting area. How do I get it to mimic the left sidebar on the right? Any ideas anyone?

i was confused with the code as i was using 2 lines in functions.php
if (function_exists(‘register_sidebars’)) register_sidebars(1);
if (function_exists(‘register_sidebars’)) register_sidebars(2);

my bad as it screwed my head for 30 min, but its ok now, i removed the first line as i have to use only one single code
if (function_exists(‘register_sidebars’)) register_sidebars(2);
just have to increase the number for more sidebars.

Thanks alot.

so many thanks dude, u really saved my whole life x) im tryin to desing my own wordpress theme from scratch and.. i was soooo stucked on “how can i make 2 sidebars¿? :S” thanx a lot 🙂 happy new year! haha =)

Espen Gjelsvik Reply

I have the same issue with vncomet:

I want to display my adsense blocks outside the content div on the left side, and outside the sidebar on the right side.

Does anyoneknow how to do this, Im guessing I would have to make two more columns, one on each side?

I made this sketch to show what I mean.
http://gmx.no/sketch.jpg

Great tutorial. I am using the Theme Dark Night Everything looks good until I go to the Index.php file.

That line of code isn’t in the index file or anywhere else for that matter. Am I screwed?

Billy Reply

I don’t think this works so well with 2.7. It jacks my theme all up and i’m using the default theme (modifying it myself).

Think I could bug you into looking at 2.7 and seeing if this still applys? I want to add a 3rd column (second sidebar) to the theme.

@Trisha:- my darn keyboard. lets try this again, all in one post.

there is no code built in to your css for adding an extra sidebar. You will want to add an id tag for your sidebar2. this is the code i use to style my extra sidebar, and by adding the ul and list-style:none… it will get rid of the list your complaining about:

#sidebar2 ul {
width:500px;
margin:20px auto; padding:10px;
background:white; border:1px solid #999; list-style: none;
}

then just add the div in your sidebar2.php

hope this helps

@Luke:- there is no code built in to your css for adding an extra sidebar. You will want to add an id tag for your sidebar2. this is the code i use to style my extra sidebar, and by adding the ul and list-style:none… it will get rid of the list your complaining about:

#sidebar2 ul {
width:500px; margin:20px auto; padding:10px;
background:white; border:1px solid #999; list-style: none;
}

JIM –

Thanks for the reply.

I’m no CSS expert, but I’m a decent tinkerer. I’ve been fidgeting with the widths, etc. and can’t seem to get things to fit correctly.

As you can see at my site (http://touchingharmstheart.com/), I’ve put placeholder text where the “sidebar1” and “sidebar2” are placed.

I can’t seem to get “sidebar2” to respond to CSS (there’s not a tag for it in my theme’s style sheet). The CSS also seems to think that “sidebar2” is a list of some sort. I’m flummoxed.

I’ll keep tinkering, but I’m convinced I need some CSS guidance. Any recommendations?

Luke, I misread your post. If it is showing but not in the right place, ( maybe under ) everything, then it is a CSS problem for sure .There may not be enough width to handle everything.

JIM

Luke,

I struggled for weeks trying to make sidebar additions work, in reality the addition tutorial is correct, but the layout may not handle it.

Look at the Daily press theme here on BohBlog, it is really good, has 2 sidebars on right under another sidebar.

hope this helps

JIM

Greetings …

This tutorial is easy to follow and (almost) gave me great results. My problem:

I’ve tried placing the “” tag **everywhere** in my index.php but it will not sit in a sidebar position. That is to say, it appears and it works, it’s just in the wrong position on my blog.

I’m using a pretty old theme (Water 1.0 – http://wordpress.org/extend/themes/water) so perhaps a 2nd sidebar is impossible. Can anyone let me know?

Or is there a way to create a 3rd column in which to place the 2nd sidebar?

Thanks …

Josh Reply

This is SO helpful. AND … what I’d REALLY love is a sidebar that scrolls independently, so that it remains visible no matter how far down in the blog someone scrolls.

Is there a way to implement this?

Jai,

Why can this line

Not be included in this code

You can see I tried but it will not show up on index.php after the category listings.

Daily Press Theme

Thanks

Jim

Jim

@Rafael Marrero:-

As Jai mentioned, not all themes can accept the extra sidebar, mine did not. For days I adjusted css and still no good. I found “DAILY PRESS” theme here on BlogOH!Blog andit is really super. Check out my site to see it.

JIM

I currently have a theme on our website that’s a single column, no sidebar. When I followed your steps to add a sidebar I couldn’t make it all the way through the steps because it would give me errors (line3) etc. I would have to re-upload the original themes *.php files to fix it. Bottom line, What am I doing wrong?

Hey Guys,

Don’t be pernickety with Jai. I found his tutorial very useful, and I have an extra sidebar.

You do need to know a little about the inner workings of WP to get this to work, even if it is not too difficult.

Be patient!

Best,

Alex

@Jai:-

Thanks Jai, That is exactly what I thought. It would so easy to just get another theme that has what I want, but I have put in a lot of time and learning on mine, so someday i will get it all added.

THANKS

Jim

Jai Reply

@JIM:- Jim,

Sometimes a tutorial cannot apply on every theme since every theme is built differently. You might have to do more than what’s written in the tutorial. I will advise you to take the help of a good coder because I think your theme needs more work.

Jai Reply

@moshu:- Please read carefully all the comments that have been posted before you. People have definitely benefited and have been able to add an extra sidebar. So, please do not make superficial comments and spread hate just because you do not have the calibre to understand a tutorial.

@moshu:-

Moshu,

I have seen your expertise elsewhere. The theme I used has only one sidebar on the right. I want to add another one on the left for ads.

Please point me in the right direction to find out how to do this.

THANKS

Jim

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.

@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

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

@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

@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

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.

nast0 Reply

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

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

love love Reply

HEY THE NEW SIDEBAR AUTOMATICALLY CODES WITH BULLETS. HOW DO I GET RID OF THAT? I’VE TRIED EVERY REMEDY AND NOTHING IS WORKING!

Haldan Reply

I’ve gotten everything to work, except the alignment, as you mentioned might be a problem.

I can’t seem to get my new, 4th, column to sit next to the others, it keeps tucking itself below the 3rd column. I’ve tried extending the fixed width to fit it all, but i can’t get it to move. How do I fix this?

any help would be greatly appreciated.

rohin Reply

anyone use Flash news theme from woothemes ? I recently bought it a while ago and can not for the sakes of me , get any kind of sidebar running on it.

It’s either you use their already pre-made sidebar or that’s it.

After I tried to follow your directions it seems to work for half a second then disappears.

blogo**** Reply

Hi,

and thanks for this turotial ! I havn’t applied it now, because I have question first.

I have a theme with two sidebars at the right. Is it possible with your method a third sidebar, at the left corner?

thanks in advance.

ninku Reply

my sidebar functions starts like this
if ( function_exists(‘register_sidebar’) )
{
register_sidebar(array(
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));
}
how to make my sidebar increase??thanks in advance.

just wanted to say a massive thank you for this article…

it did require a few more detailed changes for my theme, but am delighted to report that after a root around my files, I manage to make the necessary changes.

it looks lovely!

Hi Jai!

I have been looking for a tutorial, however I cannot see the codes you posted in your post I can only see the first part of codes;

“if ( function_exists(‘register_sidebars’) )
register_sidebars(2);
?>”

But the rest are just blue boxes with nothing.
Is it a problem on my end? I really need this tut and I tried to view the codes in both FF and IE.

Noobatron..

Great mod – and all successfully changed although the problem I have now is that the widgets I use in the admin for sidebar 2 do not show on the sidebar 2.

I simply get the same as sidebar one even though the admin says differently.

Thanks

Matt Reply

I noticed this post was published in Nov 2007. Does the trick work with new versions of WP? Or will things go wrong when I update it later?

I followed your steps exactly and am getting this:
Warning: Cannot modify header information – headers already sent by (output started at /home/tablefou/public_html/momcooks/wp-content/themes/rockinruby-10/functions.php:6) in /home/tablefou/public_html/momcooks/wp-admin/theme-editor.php on line 60

I don’t understand what adding a second sidebar has to do with the header. Any suggestions?

Tom Reply

Hi, I am using the GreyLagoon theme and after going through tutorial step by step, I get this error message:

Parse error: syntax error, unexpected ‘;’ in /home/oldwiza1/public_html/wp-content/themes/graylagoon-01/sidebar2.php on line 5

I believe my error may be related to where I post this code:

Can you help me?

adam Reply

tried this. messed up my wordpress site. Using wp 2.5. Just lettin’ people know. I’m not sure how successful this will be with recent versions of wp

DBR Reply

This was exactly what I was looking for but could you perhaps elaborate or do a tutorial on the following for we novices brave enough to attempt this?

“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 :-”

Or even provide a link to where we can find this info?

Cheers,
DBR

I am currently using the Silverlight-01 Theme. (Thank you very much!)

The theme says it’s supposed to come with 2 sidebars. I tried dragging widgets into both
Sidebar 1 and Sidebar 2 under >Presentation >Widgets. However, only the widgets from side Sidebar 2 show up (they show on the right hand side of the screen). How can I make the widgets from Sidebar 1 show up on the left hand side of the screen?

Since I think the theme was meant to have 2 sidebars, I didn’t want to mess with the code and screw it up.

However I did create the files sidebar1.php and sidebar2.php as the article describes.

Thanks for the help.

Chris

Hi, Just following the post, which seemed easy enough. I am using one of your themes Kelabu and wanted to add a right side bar. All was good until the editing of the index.php. I cannot get the right side bar to appear. Can you help me any further?

Jai Reply

@EssEtch: After the line which says

if (function_exists(‘register_sidebar’))

just add this line :-

register_sidebars(2);

where 2 is the no. of sidebars that you want to have in your wp theme.

EssEtch Reply

My functions.php looks like this:

”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));
?>

How do I change this? Thanks.

I followed step by step…. in index.php there is no ” include sidebar” its somethig with “get sidebar()”.
I’m not seeing the second sidebar 🙁

in the widgets section i got two sidebars that i created from your tutorial.. it’s great! Just trying to figure out more or less the same as “amr” is trying to figure.. how to get the bar over to the far right side instead of in the middle of the blog : )

Your tutorial on how to add a sidebar literally did save me from switching from a theme I love! Thanks!
I have just one question. How can I make it so the sidebar will be on the left side of my blog?

Thanks so much for this tutorial-I needed an easier version than the one I was using as reference(some folks just make things harder than they have to be)your method really helped me out.

Jai Reply

@ayahshiva : Yes, you can apply the same procedure to a theme that has 2 columns. Just increase the number to 3 in the functions.php file. Then you will have to create three sidebar files and include them in your index.php file. This number also changes in the sidebar file code accordingly.

Leave a Reply to anil Cancel reply

Your email address will not be published. Required fields are marked *