Jean is an Internet and Multimedia specialist with a keen interest in music, technology, business, sports and psychology.
Jean Galea
Internet Consultant in Malta
Jean Galea: entrepreneur and internet specialist. Holding an M.Sc. in Multimedia & Internet Computing from Loughborough University, Jean specialises in web design and development, email marketing systems and general internet consultancy.
WordPress: Include a different sidebar for certain pages
Here’s how to include different sidebars for particular pages:
<?php
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('archives')) {
get_sidebar('archives'); // includes sidebar-archives.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
} else {
get_sidebar(); // includes regular sidebar.php
}
?>
If you want to extend it further, such as displaying different sidebars for different categories, use this code:
< ?php
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('archives')) {
get_sidebar('archives'); // includes sidebar-archives.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
} else {
get_sidebar(); // includes regular sidebar.php
}
?>
Related posts:
- How to add multiple Sidebars to WordPress
- Duplicating Pages/Posts quickly in WordPress
- How to set a home page and blog page on WordPress
- Tabbed Content in WordPress Posts/Pages
- Password Protecting Your WordPress Website or Blog
Leave a Reply
Thank you for reading this blog. Please check back for new posts.

