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 have the following code

// in functions.php
register_sidebar(array(
    'before_widget' => '<section>',
    'after_widget' => '</section>',
    'before_title' => '<h3>',
    'after_title' => '</h3>',
));

// in sidebar.php
if (!function_exists('dynamic_sidebar') || !dynamic_sidebar()) : ?>
    // static sidebar here ..

I find that the static sidebar is what renders even if I add widgets in the dashboard. I'm not sure if WP3.2 caused it as I never tried using dynamic sidebar before updating

share|improve this question
add comment

1 Answer

You should add the name and id parameters to your register_sidebar() argument array:

'name'=>'Sidebar Name',
'id'=>'sidebar-slug',

Like such:

register_sidebar(array(
    'name'=>'Sidebar Name',
    'id'=>'sidebar-slug',
    'before_widget' => '<section>',
    'after_widget' => '</section>',
    'before_title' => '<h3>',
    'after_title' => '</h3>',
));

Then call the id of the Sidebar in your dynamic_sidebar() call:

if ( ! dynamic_sidebar( 'sidebar-slug' ) ) {

}

By the way: you don't need to include a function_exists( 'dynamic_sidebar' ) ) conditional; this functionality has been in WordPress since version 2.8.

share|improve this answer
add comment

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.