Balkhis - Vision For Success

How to add a dynamic sidebar in WordPress?

Dear Readers, I would like to thank you for reading this post. I highly value your feedback and would like to know more about my readers. Follow me on Twitter

Do you ever wonder that you have one sidebar, but you want to display widgets in other places, and they don’t come in with manual codes that you can enter in the page and avoid using the widgets. Well there are some widgets that doesn’t have the manual tags. The solution to those is to add more than one dynamic sidebar in wordpress and display them where you want. I like this because I can manage everything from my wordpress admin panel and have everything where I want on the template. Kill two birds with one stone.

I have made a detailed video, which I will recommend you to watch because that will make the steps much more understandable, but I think you need to visit here to actually get the codes because it might not be as clear in the video.

First of all, Open your functions.php which is located in the themes folder.

[raw]
<?php

if ( function_exists(‘register_sidebars’) )
register_sidebar();

?>

[/raw]

By default it shows something like I have put above. Replace these codes with the ones below:

[raw]

<?php
if ( function_exists(‘register_sidebars’) )
register_sidebar(’2′);
register_sidebar(’3′);
register_sidebar(’4′);
?>
[/raw]

You can add the numbers as you go. Remember you start with 2 because sidebar 1 is already defined.

Now is the part where you need to see the video because that explains better with live tutorial.

You go to the admin panel, and get to the widgets page, and you will see more than one sidebar there. Upload the widgets in the desired sidebar. Say you want to display the mybloglog recent visitor widget in the footer. You copy that widget in your sidebar 2 or whichever one.

Than open the file where you want to display the codes. In our case footer.php

[raw]
<?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(2) ) : else : ?>

<?php endif; ?>
[/raw]

Add the codes above, and make sure you change the sidebar number.

This should do it. Enjoy your dynamic sidebar. This will make your life so much comfortable now because you can edit settings through the admin panel rather than editing each plugin file individually.



To stay updated with the blog, please consider subscribing to my full feed RSS. You can also subscribe by Email and have new posts sent directly to your inbox. I hate spam as well, so I promise you that you will not be spammed.
Add to Social Bookmarks:
Add this Article to Digg Add this Article to Stumbleupon Add this Article to Del.icio.us Add this Article to Reddit Add this Article to Newsvine Add this Article to Technorati

Subscribe to Balkhis via RSS
Subscribe to Balkhis via Email Pimp My Blog