We all like WordPress themes. However, most of these themes have only one sidebar. What if you need one more sidebar? For example, you want to create different sidebars for different categories.
In this tutorial, I will show you how to add an additional sidebar in WordPress theme. I am assuming that you have some basic knowledge of HTML and PHP.
Firstly, you need to register a new sidebar in your functions.php file in your theme folder. If you cannot find this file, you have to create one. If you have to create this file on your own, just open your favorite text editor to start a new file. Put the following code into this new file (functions.php):
<?php if (function_exists('register_sidebar')) { register_sidebar(array( 'name' => 'Sidebar second', 'id' => 'sidebar-second', 'description' => 'This is the second siadebar.', 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h2>', 'after_title' => '</h2>' )); }
Secondly, you need to create the second sidebar (sidebar-second.php) in your theme folder. Put this code in this new file.
<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar second')) : else : ?> <!-- All this stuff in here only shows up if you DON'T have any widgets active in this zone --> <?php endif; ?>
Finally, you can call this second sidebar in your theme. For example, you want to put this second sidebar in your category Training. Then create a new php file with name of category-training (category-training.php) in your theme folder. Put the following code in the category-training.php file:
<?php get_sidebar('second'); ?>
Now you have an additional sidebar for the category training. You also can add widgets from your WordPress Dashboard-Appearance-Widgets.