Multiple widget sidebars in WordPress
When customizing this website I thought it would be cool to have different sidebars in different pages/post. I wanted to display some nice widgets but many of them slow down the load speed of the blog, so I decided to figure it out how to have different sidebars in my WordPress (the best resources I found was Widgetizing Themes and Widgets API from Automattic). This way I would have those ‘nice’ heavy widgets only in my home page and other different widgets in the single post/pages.
First, you have to make a copy of sidebar.php, rename the new file to sidebar2.php and then modify the code:
Find this line:
<p>
<?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar() ) : else : ?>
</p>
and make the following changes:
<p>
<?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(n) ) : else : ?>
</p>
where n is the name of the new sidebar you created before (for example …&& dynamic_sidebar(2)… means that this file (sidebar2.php) will host the widgets added via Design>>Widgets>>Sidebar2 in the Admin Panel.
Then, you have to register the new sidebar. To do that, you need to modify the file functions.php
located in the main folder of your theme (the same folder of sidebar.php).
Look for this lines at the end:
<?php
if ( function_exists(‘register_sidebar’) )
register_sidebar();
?>
and make the following changes:
<?php
if ( function_exists(‘register_sidebars‘) )
register_sidebars(n);
?>
where n is the number of different sidebars you would like to have.
Finally, you have to add the new sidebar to all those pages you will like to have a different sidebar (in my case: Single Post page and Page)
Open the files: (single.php, page.php, archive.php, etc)
Look at the end for this line:
<?php get_sidebar(); ?>
and replace it for:
<?php include (‘sidebar2.php’); ?>
where sidebar2.php is the file we created before as our new sidebar.
Duplicate widgets in WordPress
Now that you have created an additional sidebar you will notice that the widgets you already used in the original sidebar cannot be used again. To solve this issue I found a post named “WordPress Duplicate Sidebar Widgets” from Lancelhoff.com. You can download a plugin directly from this post and follow their instructions to duplicate any widget you want. It’s very easy to use =)
Well, it works well for me, I hope the same for you. Sorry for the language… this is my first post in english.


| 3 votos, 4.33 / 5















