Title: Multiple Sidebar Call Problem
Last modified: August 19, 2016

---

# Multiple Sidebar Call Problem

 *  [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/multiple-sidebar-call-problem/)
 * I’m trying to call in a sidebar but I just can’t get it to work. I have 4 different
   pages and 4 different sidebars I’d like to display. I’ve set up the sidebars 
   and they appear okay in the Widget panel but here’s my code for the call dependent
   on page – which I can’t get to work:
 *     ```
       <?php if ( is_page('accommodation') ) {
       include(TEMPLATEPATH.'/sidebar2.php');
       } elseif ( is_page('see') ) {
       include(TEMPLATEPATH.'/sidebar2.php');
       } elseif ( is_page('directions') ) {
       include(TEMPLATEPATH.'/sidebar3.php');
       } elseif ( is_page('16') ) { ?>
       include(TEMPLATEPATH.'/sidebar4.php');}
       <?php } ?>
       ```
   
 * Any help or idea would be very much appreciated

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/multiple-sidebar-call-problem/#post-1115265)
 * Rename your sidebar files sidebar-accommodation.php, sidebar-see.php, sidebar-
   directions.php and sidebar-other.php. Then try using:
 *     ```
       <?php
       <?php if ( is_page('accommodation') ) get_sidebar('accommodation');
       elseif ( is_page('see') ) get_sidebar('see');
       elseif ( is_page('directions') ) get_sidebar('directions');
       elseif ( is_page('16') ) get_sidebar('other');
       ?>
       ```
   
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/multiple-sidebar-call-problem/#post-1115275)
 * Umm, I’m getting a little confused with this!?
 * I’ve changed pages for page ids and called the sidebars 1-4, so it now reads:
 * <?php if ( is_page(‘4’) ) get_sidebar(‘2’);
    elseif ( is_page(’12’) ) get_sidebar(‘
   2’); elseif ( is_page(’14’) ) get_sidebar(‘3’); elseif ( is_page(’16’) ) get_sidebar(‘
   4’); ?>
 * It just appears to be bringing in the same sidebar on each page even though I
   have different widgets on each.
 * With the sidebar.php files do I simply duplicate the first one and title them
   sidebar-1.php etc etc.
 * I’m a bit confused?!
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/multiple-sidebar-call-problem/#post-1115291)
 * I’ve managed to insert one of the sidebars I created (just to see if they were
   working!) by using this code:
 *     ```
       <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-4') ) : ?>
       <?php endif; ?>
       ```
   
 * But I really need differerent sidebars for each of the 4 pages.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/multiple-sidebar-call-problem/#post-1115292)
 * [http://codex.wordpress.org/Function_Reference/get_sidebar](http://codex.wordpress.org/Function_Reference/get_sidebar)
 *  Thread Starter [greencode](https://wordpress.org/support/users/greencode/)
 * (@greencode)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/multiple-sidebar-call-problem/#post-1115297)
 * I’m at a loss as to know what to do here. I have this:
 *     ```
       <?php
       if ( is_page('4') ) :
         get_sidebar('1');
       elseif ( is_page('12') ) :
         get_sidebar('2');
       elseif ( is_page('14') ) :
         get_sidebar('3');
       elseif ( is_page('16') ) :
         get_sidebar('4');
       endif;
       ?>
       ```
   
 * and in the functions I’ve created these:
 *     ```
       if ( function_exists('register_sidebar') ) {
       		register_sidebar(array('name'=>'sidebar-1',
               'before_widget' => '',
               'after_widget' => '',
               'before_title' => '<h2>',
               'after_title' => '</h2>',
           ));
           	register_sidebar(array('name'=>'sidebar-2',
               'before_widget' => '',
               'after_widget' => '',
               'before_title' => '<h2>',
               'after_title' => '</h2>',
           ));
           	register_sidebar(array('name'=>'sidebar-3',
               'before_widget' => '',
               'after_widget' => '',
               'before_title' => '<h2>',
               'after_title' => '</h2>',
           ));
           	register_sidebar(array('name'=>'sidebar-4',
               'before_widget' => '',
               'after_widget' => '',
               'before_title' => '<h2>',
               'after_title' => '</h2>',
           ));
       }
       ```
   
 * The sidebars appear to be showing up okay in my Widgets panel as:
 * sidebar-1
    sidebar-2 sidebar-3 sidebar-4
 * So I have no idea why it’s not working. It seems to just default to the first
   sidebar I have?!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Multiple Sidebar Call Problem’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [greencode](https://wordpress.org/support/users/greencode/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/multiple-sidebar-call-problem/#post-1115297)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
