Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Environment: WP 3.5, Twenty Twelve child theme. I created a custom template. Now, I'd like to display the built-in sidebar-2 in this custom template page (instead of the default sidebar-1). sidebar-2 is already registered by twenty twelve functions.php. I read a bit about get_sidebar and how to activate other sidebars, but I'm still a bit confused. To activate sidebar-2 on this custom template I created a file sidebar-customtemplate.php in my child theme directory with this content:

<?php if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
    <div id="secondary" class="widget-area" role="complementary">               
        <?php dynamic_sidebar( 'sidebar-2' ); ?>
    </div><!-- #secondary -->
<?php endif; ?>

Then in my custom template file I replaced get_sidebar(); with <?php get_sidebar( $customtemplate ); ?>. Then I added some widgets to the sidebar-2 (from Appearance - Widget), but in the home page still sidebar-1 is displayed! Why? :(

share|improve this question

3 Answers 3

you can put this code in your functions

add_action( 'init', 'register_my_menus' );
function register_my_menus() {
            'menu-1' => __( 'Head' )

and this code, in the place you want your second menu

<?php wp_nav_menu( array( 'theme_location' => 'menu-1' ) ); ?>

and than, you can control your new menu, through the menu section in the admin panel

share|improve this answer
Uhm, no. I don't need to register a menu. I need to use the already registered by default (in twenty twelve) "sidebar-2" in a custom template page. –  MultiformeIngegno Dec 23 '12 at 15:31
Oh, sorry, i didnt noticed. did you check if its passing the if condition? –  Iliya Reyzis Dec 23 '12 at 15:37
up vote 0 down vote accepted
<?php get_sidebar( 'customtemplate' ); ?> 

did the thing :)

share|improve this answer

Rename that sidebar-2 into sidebar-sidebar2.php and after use this code

<?php get_sidebar('sidebar2');?>

hope its may work

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.