First, let's make sure we're clear regarding terminology; there are two possible meanings for "sidebar" in your question:
- A dynamic sidebar, i.e. a Widget area, created via call to
register_sidebar()
in functions.php
, and included in the template via call to dynamic_sidebar()
.
- A template part, called via
get_sidebar( $slug )
, the markup of which is defined in a template-part file named sidebar-$slug.php
.
The two can, but do not have to, be related. For instance, calls to dynamic_sidebar()
can, but do not have, to reside within a sidebar-$slug.php
template-part file.
Let's step through both scenarios:
Dynamic Sidebar "Mountain"
So, assuming that your "Mountain" sidebar is a Widget area, you'll have something like the following defined in functions.php
:
<?php
function wpse46048_register_dynamic_sidebars() {
// Register "Mountain" Widget area
register_sidebar( array(
'name' => 'Mountain',
'id' => 'mountain',
'description' => 'Mountain Widget area',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<div class="title widgettitle">',
'after_title' => '</div>',
) );
}
add_action( 'widgets_init', 'wpse46048_register_dynamic_sidebars' );
?>
...and then, somewhere in your template, you will call either this:
<?php
if ( ! dynamic_sidebar( 'mountain' ) ) :
// Default content output goes here
endif;
?>
...or else just this (if you don't want to output any default content):
<?php dynamic_sidebar( 'mountain' ); ?>
Then, you would populate the Widgets for this area via Dashboard -> Appearance -> Widgets
, by dragging-and-dropping Widgets into the "Mountain" Widget area.
Template-part Sidebar "Mountain"
Assuming that your "Mountain" sidebar is a template part, you'll first define the markup for that template part in a file called sidebar-mountain.php
. Then, you'll include that template-part file in the template via:
<?php get_sidebar( 'mountain' ); ?>