Add dynamic sidebars in your wordpress themes

Hello Friends !!

You like wordpress theaming and working with wordpress ? But what is this, there is only one sidebar with your theme ? Then how can you add new sidebar ?

I have faced same problem. Since last few days, I am working on wordpress project. I am doing theaming on wordpress.

At one point, I want extra sidebar for my theme.Now at that time I am doing lots of search and I found the solution. Today I will show you how to add dynamic sidebars in your wordpress theme ?

First of all see all the files in your perticular theme. Do you find file called functions.php. If no, then create one php file and save it as functions.php. Just open this file and write below code in it..

<?php
if ( function_exists(‘register_sidebars’) )
register_sidebars(2);
?>

After this save file as functions.php in theme folder. If your theme have more then one sidebar, then you can find functions.php file in your theme folder. You can change the code as you want. Now What the code douse actually ? register_sidebars(n) this function register n no of sidebars in your theme. Now when you go to your wordpress admin and browse the widgets,  you can see n no of sidebars in admin.

Now time comes for actual coading. Your theme have one sodebar.php. For these exmple, we make two side bars so we need two sidebar files. So copy sidebar.php and make new sidebar file named sidebar2.php .Open this sidebar2.php file and write below code in it:

<div>
<ul>
<?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(2) ) : else : ?>
<?php endif; ?>
</ul>
</div>

Hoooreey !! Our sidebar is ready. Now How to use this side bar in index.php ? You have to just write below code where you want this new sidebar :

<?php include (TEMPLATEPATH . ‘/sidebar2.php’); ?>

Thats it. Using this technique, you can add no of sidebars on your wordpress themes. If you have any confusion regarding this or any question regarding wordpress customization or if you want to make site in wordpress then feel free to contact me.

Thanks !!

  • Pingback: Add dynamic sidebars in your wordpress themes | Tutz - Best Tutorials()

  • http://www.talentsfromindia.com/hire-dedicated-developers-programmers.html Dedicated Developer

    thank you very much for sharing this post with us….
    this post providing more information about coding part of php and its function,,,
    this post is very usefull for all php developers….

  • http://www.watches-user.com Guess men's watches

    oh,my god ! Thant's good article. I found it a long time. We like reading article ! We will always come come here reading. thanks a lot.

  • Dinesh Karki

    thank for the helpful post

  • WordPress Shopping Cart

    This post helps me a lot. Thanks for this.

  • http://www.sufalamtech.com/ Web Development Company

    In WordPress Platform you can set dynamic widget option to change any time as per needs. I have seen your plugin for sidebar to adjust in wordpress. Its a awesome features. Thanks for sharing your thoughts.