Title: Adding a second sidebar to sidebar.php
Last modified: August 22, 2016

---

# Adding a second sidebar to sidebar.php

 *  [artlover578](https://wordpress.org/support/users/artlover578/)
 * (@artlover578)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-a-second-sidebar-to-sidebarphp/)
 * Hello I was wondering if someone could help me out. I have a registered 2 sidebars:
 *     ```
       function theme_widgets_init() {
       	register_sidebar( array(
       		'name'          => __( 'Sidebar', 'themename' ),
       		'id'            => 'sidebar-1',
       		'description'   => 'Sidebar for all pages',
       		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
       		'after_widget'  => '</aside>',
       		'before_title'  => '<h1 class="widget-title">',
       		'after_title'   => '</h1>',
       	) );
   
       register_sidebar( array(
       		'name'          => __( 'Sidebartwo', 'themename' ),
       		'id'            => 'sidebar-2',
       		'description'   => 'Sidebar for specific page',
       		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
       		'after_widget'  => '</aside>',
       		'before_title'  => '<h1 class="widget-title">',
       		'after_title'   => '</h1>',
       	) );
   
       }
       add_action( 'widgets_init', 'theme_widgets_init' );
       ```
   
 * I would like to add the second sidebar to the sidebar.php loop so that if there
   is nothing in the side bar it shows a few things.
 *     ```
       <div id="secondary" class="widget-area" role="complementary">
       		<?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?>
   
       			<aside id="search" class="widget widget_search">
       				<?php get_search_form(); ?>
       			</aside>
   
       			<aside id="archives" class="widget">
       				<h1 class="widget-title"><?php _e( 'Archives', 'theme' ); ?></h1>
       				<ul>
       					<?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
       				</ul>
       			</aside>
   
       			<aside id="meta" class="widget">
       				<h1 class="widget-title"><?php _e( 'Meta', 'theme' ); ?></h1>
       				<ul>
       					<?php wp_register(); ?>
       					<li><?php wp_loginout(); ?></li>
       					<?php wp_meta(); ?>
       				</ul>
       			</aside>
   
       		<?php endif; // end sidebar widget area ?>
       	</div><!-- #secondary -->
       ```
   

The topic ‘Adding a second sidebar to sidebar.php’ is closed to new replies.

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [artlover578](https://wordpress.org/support/users/artlover578/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/adding-a-second-sidebar-to-sidebarphp/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
