Sometimes you want to have a different sidebar on your blog than you have on your other pages. What you are really doing here is creating a new widget area, or a widgetized area as they call it in the WordPress Codex. And this new area is where you will add your blog sidebar. Here’s a quick tutorial on how to achieve this.
Create a new php file with the name of your new sidebar. It must start with the name “sidebar” as that is what tells WordPress it’s a sidebar file. So something like sidebar-bloginfo.php. We’ll get back to this file in a minute…
In your functions.php you must add the code to actually create the new widget area, so copy and paste this code into your functions.php file:
'My Blog Sidebar', 'id' => 'my-blog-sidebar', 'description' => 'This will be my Blog sidebar.', 'before_widget' => '
', 'before_title' => '
‘after_title’ => ‘
' )); } ?>
You can change the Name, ID and Description to whatever suits your purposes. Also you can change the div ID and class to that which is used by your theme, but with this code you shouldn’t have to. Now that we have created the new widgetized area (you can see it in the Admin file under Appearance>Widgets) we now need to tell WordPress where that area will be. In our case we are adding it to the new sidebar we created so…
Paste the following code into the sidebar-bloginfo.php file you created in Step 1
Your Widgets will appear here after you add them in the Admin area
In the code above you will see Div IDs and Classes. My theme uses “grid_4” and “widget” these will vary from theme to theme. Best place to look is in your theme’s actual sidebar.php and see what your theme is using for its IDs and classes. You may have to play with this part a little to get it right.
Now as you probably already know, WordPress uses the function get_sidebar() to call the side bar into the template file. But obviously we don’t want the regular sidebar on this particular page we want the new sidebar we created. So you have to find the file that you want to add the new sidebar to. This will be different for every person and can be different for every theme too. But let’s assume it’s archive.php or home.php. So you would open that file and where you see get_sidebar() you just need to change it so that it gets YOUR sidebar like this get_sidebar(‘bloginfo’);
Now upload all these files to your theme’s child theme folder.
You’re done! Just go to the Admin panel under Appearance > Widgets and add widgets to your new widgetized sidebar!