Multiple Sidebars and Changing the Blogroll's Name in WordPress
04-15-2008, 05:42 PM
|
Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 54
|
I have two unrelated (I think) questions about Word Press. I am wondering if it is possible to:
1 - Have two different sidebars, one that appears on the index page and another that appears on the single post page.
2 - Change the name of the Blogroll
Thanks!
|
|
|
|
04-15-2008, 07:39 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 199
Name: Steve
|
1. Yes.. Name one Sidebar1 and the other Sidebar2 then in the index page call Sidebar1 and in the single page cal Sidebar2
2. Yes.. Go in to Manage -> Categories in your admin panel and edit the category and change the name to something else..
|
|
|
|
04-15-2008, 08:59 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 54
|
Thank you. I got the Blogroll renamed and created a new sidebar. One more problem, though. When I go into the second sidebar, I cannot add some widgets such as the Blogroll one, the search one, the archives one, and some others.
Any idea why?
Thanks!
|
|
|
|
04-15-2008, 09:18 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 199
Name: Steve
|
You probably didn't copy the top part of the code from Sidebar1 that loads the widgets..
Make sure the sidebars have pretty much the same code..
|
|
|
|
04-15-2008, 10:01 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 54
|
I just duplicated the code for the first sidebar so it should be the same.
|
|
|
|
04-15-2008, 10:51 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 199
Name: Steve
|
Gotta change the sidebar number in the code..
Code:
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>
and
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?>
|
|
|
|
04-16-2008, 04:52 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 54
|
Hmmm... the line in my file looks slightly different:
Code:
<?php /* Widgetized sidebar, if you have the plugin installed. */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
I changed it to
Code:
<?php /* Widgetized sidebar, if you have the plugin installed. */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) : ?>
for sidebar.php and
Code:
<?php /* Widgetized sidebar, if you have the plugin installed. */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) : ?>
for sidebar2.php, but that did not help, so I changed it back.
|
|
|
|
04-16-2008, 06:11 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 199
Name: Steve
|
Looks like an old template code for an old version of WP to me.. If you are running 2.5 run the code I gave you.. It's what I run..
|
|
|
|
04-17-2008, 06:15 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 54
|
I am running 2.5 having upgraded just a little while ago. I used the automatic update plugin if that matters...
|
|
|
|
04-17-2008, 07:24 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 8,663
Name: Steven Bradley
Location: Boulder, Colorado
|
The code you had (specifying the different sidebars) is right, but there's one more step. Since your theme was already widgetized you should have a file called function.php in your theme.
By default it registers one dynamic sidebar. You need to tell it you now have 2 sidebars.
You'll see:
if ( function_exists('register_sidebar') )
at the top of functions.php. I think all you need to do is change it to:
if ( function_exists('register_sidebar(2)') )
and then use the same code you tried above.
|
|
|
|
04-17-2008, 09:17 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 54
|
I had some code like that in there already, but the original code was slightly different. It looked like this:
Code:
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
so I just added the new code to the end so now it looks like this:
Code:
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
if ( function_exists('register_sidebar') )
register_sidebar(2);
Still, it does not let me add some widgets.
|
|
|
|
04-18-2008, 05:09 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 8,663
Name: Steven Bradley
Location: Boulder, Colorado
|
My bad about the code above. What you were trying to do was closer to being right than what I posted.
I think the issue might be due to the array and what you did above needs to be done a little differently.
What you might need to do is something more like:
PHP Code:
if (function_exists("register_sidebar")) { register_sidebar(Array("name" => "sidebar1")); register_sidebar(Array("name" => "sidebar2")); }
I think you might need to name both sidebars too. You don't have to call them sidebar 1 and 2 either. You should be able to name them anything you want.
Here are a couple of posts that hopefully help
Wordpress 2 Widget sidebars is a short post which is mostly the code I posted above.
WordPress Widgets is a quick tutorial on widgets. The links for themes and the API are probably the most relevant.
|
|
|
|
04-19-2008, 08:44 AM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 54
|
Thanks for the links. The second one seems very useful, but it basically just confirmed what I had already guessed. I am now using code from the examples on the second site, but I still have the same problem. (I did try the code you suggested, but it had the same result as everything else.) Here is the current code I am using:
functions.php
Code:
register_sidebars(2, array('name'=>'Sidebar %d'));
sidebar.php
Code:
<?php /* Widgetized sidebar, if you have the plugin installed. */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Sidebar 1") ) : ?>
sidebar2.php
Code:
<?php /* Widgetized sidebar, if you have the plugin installed. */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Sidebar 2") ) : ?>
I did notice one thing which might be important. (I might have already mentioned it, actually.) If I remove one of the widgets that I cannot add to sidebar 2 from sidebar 1, I am then able to add it to sidebar 2.
Thanks!
|
|
|
|
04-19-2008, 06:14 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 8,663
Name: Steven Bradley
Location: Boulder, Colorado
|
Is the idea then that you can't add the same widget to both sidebars? I think that's a very different problem. Sorry if I misunderstood.
I'm not sure why you'd want to add the same widget to two sidebars in the first place, but I'd guess the problem is it can't exist in both places at once. You probably need to make a second copy of the widget and give it a different name in order to add it to both. To the system it would be two different widgets even if they end up with the same functionality.
|
|
|
|
04-19-2008, 10:09 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 54
|
Yes, that seems to be the problem. Anyway, you helped me get a better idea of how the code really works.
It sounds like two copies should work, but how do I make another copy?
Thanks!
|
|
|
|
04-21-2008, 05:23 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 8,663
Name: Steven Bradley
Location: Boulder, Colorado
|
You would need to find the file or files used to create the widget you want to copy and then obviously make a copy of them with a new name.
I'm not sure where the files for the blogroll and other things you mentioned at the top are located, but if it's a widget you added later it should be in the plugins folder.
|
|
|
|
04-23-2008, 06:07 PM
|
Re: Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
Posts: 54
|
It is a built-in widget. I cannot find the file where it is. Anyone know where the default widgets are used?
|
|
|
|
|
« Reply to Multiple Sidebars and Changing the Blogroll's Name in WordPress
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
| | |