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.

I stumbled upon avery strange problem while creating a sidebar for my wordpress theme using the get_sidebar() function in header.php.

I inserted the following code in function.php:

function myfunc_sidebars_init() {
    register_sidebar(array(
        'name' => __('Main Sidebar', 'mytheme'),
        'description' => __('Widget area for the main sidebar.', 'mytheme'),
        'id' => 'sidebar-main',
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
        ));
    }
}
add_action( 'widgets_init', 'myfunc_sidebars_init' );

My sideber.php looks like this:

<div id="sidebar1" class="fluid-sidebar sidebar span4" role="complementary">

<?php if ( is_active_sidebar( 'sidebar1' ) ) : ?>

    <?php dynamic_sidebar( 'sidebar1' ); ?>

<?php else : ?>

    <div class="alert alert-message">

        <p><?php _e("Please activate some Widgets","mytheme"); ?>.</p>

    </div>

<?php endif; ?>

</div>

I also selected the sidebar in Appearance->Menus in the admin panel and all default widgets are added to the sidebar in Appearance->Widgets (Search, Recent Posts, Recent Comments, etc.).

However after loading the theme there is an alert in the sidebar menu saying "Please activate some Widgets". Why is that and how can I fix it?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You've changed from sidebar-main in your myfunc_sidebars_init() to sidebar1 in sidebar.php. Change sidebar.php to use

<?php if ( is_active_sidebar( 'sidebar-main' ) ) : ?>

    <?php dynamic_sidebar( 'sidebar-main' ); ?>
share|improve this answer
    
Oh, thanks! That was very stupid mistake of mine.. –  Ziik Jun 27 '13 at 13:01
1  
I've chased down typos like that for hours before. Now I tend to look for stuff like that first. –  Pat J Jun 27 '13 at 13:15

Your Answer

 
discard

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.