How to add a second sidebar widget for use on separate pages or posts: The following tutorial covers the process of building a second widget compatible sidebar that can be used on specific pages or posts. Using a different WordPress sidebar for pages and posts allows the user to display different sidebar content on a given post or page. In addition, the user could add the duplicate sidebar widgets plugin to add the same widget content to both sidebars.
Adding a second widget compatible sidebar to WordPress:
This process assumes your using Kubrick or a theme based on Kubrick. Please backup any files before editing.
Navigate to Design ->Theme Editor from your WordPress admin panel
Open the functions.php file from the theme file list and find:
Replace it with the following code, then update the file:
if ( function_exists('register_sidebar') ) register_sidebar(array('name'=>'Sidebar 1',)); register_sidebar(array('name'=>'Sidebar 2',));
You should now have two widget compatible sidebars that show up under Design-> Widgets. Next we will add a Sidebar template to use for Sidebar 2 and then call it into the page or post we wish to have display the new sidebar.
Download the sidebar2.zip file and upload the sidebar2.php within to your WordPress wp-content/themes/yourthemename/ directory
Now to use Sidebar 2, simply replace the following code found in any of your template files. For example (Single Post) single.php
<?php get_sidebar();Â ?>
With the following code:
<?php include("sidebar2.php");Â ?>
Note: You can build a custom template that specifically calls in Sidebar 2 and elect to use it whenever you write a page that you wish to use this alternate Sidebar.