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..
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:
<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 :
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()