Title: Sidebar widgets in multiple sidebars
Last modified: August 18, 2016

---

# Sidebar widgets in multiple sidebars

 *  [mtweldon](https://wordpress.org/support/users/mtweldon/)
 * (@mtweldon)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/sidebar-widgets-in-multiple-sidebars/)
 * Here is where I am at: I have installed widgets and everything works fine. I 
   can get widgets to show up on the homepage and other pages, but I am trying to
   put different widgets on different sidebars on different pages. In sidebar.php
   I do two of these:
 *     ```
       <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar 1') ) : else : ?>
       <?php endif; ?>
       ```
   
 * One has ‘Sidebar 1’ the other ‘Sidebar 2’ and then in one of those one has is_home()
   the other has is_page(3)
 * but all pages display sidebar 1 and sidebar 2 for some reason.

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

 *  [Alex Cragg](https://wordpress.org/support/users/epicalex/)
 * (@epicalex)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/sidebar-widgets-in-multiple-sidebars/#post-560882)
 * have you checked your functions.php file?
    it should have the total number of
   dynamic sidebars in the brackets like so `<?php if ( function_exists('register_sidebars'))
   register_sidebars(2);?>`
 *  [Alex Cragg](https://wordpress.org/support/users/epicalex/)
 * (@epicalex)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/sidebar-widgets-in-multiple-sidebars/#post-560883)
 * oh and also in your code, it shouldn’t say `dynamic_sidebar('Sidebar 1')` it 
   should just be `dynamic_sidebar(1)` or 2 obviously
 *  Thread Starter [mtweldon](https://wordpress.org/support/users/mtweldon/)
 * (@mtweldon)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/sidebar-widgets-in-multiple-sidebars/#post-560890)
 * K have that in the functions like that.
 * I changed it to sidebar(1) and sidebar(2) but it still does the same thing.
 * here is what I am basically doing in sidebar.php
    <?php if ( function_exists(‘
   dynamic_sidebar’) && dynamic_sidebar(2) ) : else : ?>
 *  <?php /* If this is the creator page */ if ( is_page(3) ) { ?>
    <?php } ?>
 *  <?php endif; ?>
    <?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(
   1) ) : else : ?> <?php /* If this is the frontpage */ if ( is_home()) { ?> <?
   php } ?> <?php endif; ?>
 * *(‘Sidebar 1’) does the same thing as (1) I believe
 *  [Alex Cragg](https://wordpress.org/support/users/epicalex/)
 * (@epicalex)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/sidebar-widgets-in-multiple-sidebars/#post-560898)
 * if they do the same i apologise.
 * maybe try out the following:
    `<?php if (function_exists('dynamic_sidebar')) {
   dynamic_sidebar(2); } ?>` you dont need to end with and endif for this first 
   one, or maybe try
 *     ```
       <?php if ( !function_exists('dynamic_sidebar')
               || !dynamic_sidebar(2) ) : ?>
       ```
   
 * fow which you need endif.
    change 1 and 2 appropriately. they’re just other ways
   of writing it.
 * also, ive never tried having two dynamic sections in one sidebar.php so maybe
   thats what the problem is?
 * maybe do you need the is_home before. so like this
 *     ```
       <?php
       if (is_home()) { if (function_exists('dynamic_sidebar')) {dynamic_sidebar(1);
       } elseif (is_page(3)) { if (function_exists('dynamic_sidebar')) {dynamic_sidebar(2);
       }?>
       ```
   
 * not sure that you need anything else in there…
 * try them out at let me know, sorry if it isnt a straight forward fix
 *  Thread Starter [mtweldon](https://wordpress.org/support/users/mtweldon/)
 * (@mtweldon)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/sidebar-widgets-in-multiple-sidebars/#post-561291)
 * If I wanted to use two different sidebar.php files would I just create sidebar2.
   php and then put in <?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(
   2) ) : else : ?>
 * <?php /* If this is the creator page */ if ( is_page(3) ) { ?>
    <?php } ?> ?

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

The topic ‘Sidebar widgets in multiple sidebars’ is closed to new replies.

## Tags

 * [widgets](https://wordpress.org/support/topic-tag/widgets/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [mtweldon](https://wordpress.org/support/users/mtweldon/)
 * Last activity: [18 years, 11 months ago](https://wordpress.org/support/topic/sidebar-widgets-in-multiple-sidebars/#post-561291)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
