Monday, 11 June 2012

How to create Sidebars with Multiple Widgets

How to create Sidebars with Multiple Widgets
I am one of those WordPress users that love the ability to customize their front end functionality with easy to use widgets. Now what i want is to create multiple dynamic sidebars to add various combination of widgets to customize my WordPress theme even more. So i wanted help from you all guys to guide me to create Sidebars with Multiple Widgets in Wordpress. Please help me.

#2
06-08-2009
Steinbach
Member

Join Date: Feb 2009
Posts: 194
Re: How to create Sidebars with Multiple Widgets
Creating multiple widget-enabled sidebars is very similar to creating a single sidebar. Here is how:-

Basically, your theme’s functions.php file is the file that controls whether or not your Wordpress theme is “widget enabled”. Many themes already contain this file, and many do not. So if yours does not you just need to create it. Here is what you would need to put in your functions.php file in order to make your theme “widget enabled”…
Quote:


Next you need to put some php code inside your sidebar.php file in order for you to actually show the widgets on your Wordpress blog. Located your Sidebar.php file and place this code in your desired location.



Now your wordpress theme ( if it by chance was not already ) is widget enabled and can actually utilize the Wordpress Widget technology. That is the first step that must be covered.

Now you have to follow the next step that is Setting up Multiple Widget Enabled Sidebars:

Now to the good stuff. Now we want to create more of these. If you noticed, in your administration interface under Design you now have a widgets section where you can manage your widgets for your sidebar. But we need to create more of these. Here’s how we do it. Go back to your functions.php file and input the following…
Quote:
'sidebar1',
'before_widget' => '',
'after_widget' => '',
'before_title' => '

',
'after_title' => '

',
));
register_sidebar(array('name'=>'sidebar2',
'before_widget' => '',
'after_widget' => '',
'before_title' => '

',
'after_title' => '

',
));
?>
You can just continue repeating this code over and over to cover however many dynamic widget sidebars that you need. Once you are done with this, next you need to input some code in your sidebar.php file to actually present these new widget sidebars that you have created. Do this…

Sidebar1 code goes like this
Quote:


Sidebar2 code goes like this
Quote:


And on and on. You can use some simple PHP if else statements to put specific sidebars on specific pages. For example, you may want to place sidebar1 on only the homepage, and sidebar2 on the rest of the pages but not the homepage. Here’s the code I put together to accomplish this…

Quote:

That’s it! You now have multiple widget enabled sidebars running on your wordpress blog. This gives your site much more flexibility in design and functionality and can really enhance the content that you deliver to your visitors. Now you can go to your wordpress admin interface and you will see all your widget sidebars in a dropdown menu where you can drag and drop items to and from each specific sidebar. Source: chasesagum

#3
06-08-2009

Trio
Member

Join Date: May 2008
Posts: 2,752
Re: How to create Sidebars with Multiple Widgets
To create multiple sidebars, we’ll be using register_sidebars. You need to enter the code in the template of wordpress theme sites relevant wordpress widgets where you want to work.This function is similar to register_sidebar(), in that it accepts the same parameters, but it also accepts a count parameter and a name parameter. Instead of the previous code, you can use different dynamic sidebars on different areas of the template locations

#4
06-08-2009

Odalis
Member

Join Date: Jun 2009
Posts: 4,513
Re: How to create Sidebars with Multiple Widgets
Thanks for the quick helps friends. However it looks very simple, i need to go through it carefully. Anyways, i'll be back when i'll get finished doing this. That is all i needed. I appreciate your help. Keep it up.

No comments:

Post a Comment