Quick Tip 20 – Multiple WP Sidebars
Following a recent design issue on a site we built in Wordpress, we wanted to include several different sidebars depending on the page you were on, unfortunately trying to get this work was a little bit of an issue. However thanks to the code below we are now go.
By replacing this code with any mention of get sidebar in your theme you can specify your own sidebar dependent on the page you are on. See Below:

if(is_page()) {
// We're on a "page", which?
if (is_page('about')) {
// Ah, the about page!
get_sidebar('about'); // includes sidebar-about.php
} elseif (is_page('services')) {
get_sidebar('services'); // includes sidebar-services.php
} elseif (is_page('contact')) {
get_sidebar('contact'); // includes sidebar-contact.php
} else {
// if we're not any of the above pages
get_sidebar(); // includes regular sidebar.php
}
?>
So if you create a template file called sidebar-about.php and then name the template ‘about’
/*
Template Name: about
*/
?>
it will then pull in the information. Great, isn’t it!
Related posts:








Richard Giles Says:
March 30th, 2010 at 10:02 am
Hi,
I use Wordpress as a CMS. Any chance you could post a step-by-step tutorial on how to create a sidebar that displays just for the blog?
Many thanks