adding second sidebar
-
Hi there,
I’d like to add second sidebar to my theme. I did few actions but the sidebar doesn’t show up any where!
It shows up in the admin area in “widgets” but not in the site.
I did few actions to create it:1) I created another file “leftbar.php”
<div id="leftbar"> <div id="leftbar-in"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?> <!-- list Archives --> <h2><?php _e('Archives'); ?></h2> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> <?php endif; ?> </div><!-- end #leftbar-in --> </div><!-- end #leftbar -->
2) Modified sidebar.php just in this line:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) : ?>
3) changed functions.php
<?php if (function_exists('register_sidebars')) register_sidebars(2, array('before_widget' => '','after_widget' => '')); ?>
4) Changed CSS
That is it, but it doesn’t show up
Did I miss anything?
Thanks,
VadimP.S this is my blog:
http://compare-forex.com/blog/
-
I think you need to start out locating you layout code and altering that. This may be in a layout folder within your theme folder or it could be incorported into your stylesheet. There will be specifice code that describes where your <div> is located and how wide it is.
What changes did you make to CSS?
I added to the CSS file codes like this:
#leftbar{ width:160px; margin:10px auto; float:left; background:#fff }
to no avail.
Then I just deleted all changes in the CSS and left it in the original state, that is why you don’t see it now.Shouldn’t the second sidebar appear somewhere where despite changes in the CSS file?
I use firebug to make changes in the CSS, and whatever I did the second sidebar didn’t appear
Any other ideas?
Thanks,
VadAny ideas,
can any one help me with this please?
Thank you
VadAre you, actually, calling that second sidebar (leftbar.php) file anywhere into your layout?
It will never show up by “magic” – you need to include it into the index or wherever it should be according to the html code of your theme.Furthermore, you will have to modify the whole setup of that theme; e.g. let’s say a theme is 800px wide and it has a 600px width for the content + 200px for the (right) sidebar… there is no room where you can put another 160px sidebar.
Hi Moshu,
I will modify the theme, there is no problem about it.
Yes, I see in the index.php this line
<?php get_sidebar(); ?>
I thought this line calls 2 sidebars at once, isn’t it?
If it is not correct what other changes should I make?
since<?php get_leftbar(); ?>
doesn’t work
Thanks,
VadimI thought this line calls 2 sidebars at once, isn’t it?
Of course, NOT!
That calls only the filesidebar.php
, nothing else. And no, it will not work with any other filename, since it is a function defined in the WP core files that recognizes only the sidebar.php filename.For your own template files in a theme folder always use:
<?php include(TEMPLATEPATH . "/your-file-name.php"); ?>
Change only the filename, nothing else!Thanks a lot, it works!
What confused me is the theme “Fastway 10” that I used, it shows only
<?php get_sidebar(); ?>
in its template but it calls for 2 sidebars at once, there is no such line <?php include(TEMPLATEPATH . “/your-file-name.php”); ?> anywhere in the theme but it shows 2 sidebars, how it could be?
Thanks,
VadimHave you checked the functions.php of that theme? Maybe there’s a cancellation of the default get_sidebar(); function and a redefinition of it, where it includes both sidebars.
That is the thing, that I found nothing regarding this.
It just gets 2 sidebars with simple get_sidebar() code!
Check it for yourself
Vad
- The topic ‘adding second sidebar’ is closed to new replies.