0

Okay, I'm sure there is an simple explanation for this problem... it's just that I can't see it right now.

Here is my code adding widget sidebars:

add_action('widgets_init', 'starter_register_sidebars');

function starter_register_sidebars() {

register_sidebar(array(
    'id' => 'sidebar',
    'name' => __('Sidebar'),
    'description' => 'The first (primary) sidebar.',
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="widgettitle">',
    'after_title' => '</h4>',
    ));

register_sidebar(array(
    'name' => __('Main Sidebar'),
    'id' => 'sidebar-1',
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => "</aside>",
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ));

}

So when I go the admin widget area it tells me: 'Drag widgets from here to a sidebar on the right to activate them'

But there is not sidebar on the right created by the above code... I've looked at a couple of other themes at what they do, and it's not obvious what they are doing differently from me

1 Answer 1

0

Looks like the problem is with the id's.

Try putting some unique names.
For example, this doesn't works in TwentyEleven, as it registers a sidebar with the same ID:

'name' => __('Main Sidebar'),
'id' => 'sidebar-1',

From the Codex:

id - Sidebar id - Must be all in lowercase, with no spaces (default is a numeric auto-incremented ID).

3
  • Thanks for the response but that hasn't had any effect. I've now cut and paste the entire twenty eleven register_sidebar code and that isn't displaying in the widget admin area either as it would have done if twenty eleven was the active theme. This is a bit annoying but I'm sure answer is just a line of code away.
    – AndyW
    Commented Jul 15, 2012 at 6:20
  • 1
    So, it seems to me that the problem is not contained in the code you posted...
    – brasofilo
    Commented Jul 15, 2012 at 13:47
  • you were right, it is - oops
    – AndyW
    Commented Jul 21, 2012 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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