1

When I install and activate my theme, it places all of the default sidebar widgets into the first sidebar widget that appears at the top of my theme's widget collection.

However, since that widget area is a header widget, those elements distort my theme's default view when first activated (the header area gets stretched to tall to accomodate all of those widgets).

I believe this is happening because the header widget happens to be the first sidebar I'm registering in functions.php

Is there a way, short of rearranging the order of my sidebar widgets, to specify which sidebar the default widgets get assigned to?

I understand that I can rearrange the order in which I register the sidebars and the default sidebar widgets will be placed into the first one. However, in my case, I want my "header" sidebar to appear first so that it accurately reflects the top to bottom layout order of the actual widget areas. But I don't want the default sidebars to be placed into the "header" sidebar. I want them placed into the "Sidebar" sidebar (the 2nd one registered as you can see from the code below)

/* SIDEBARS
*******************************/

register_sidebar(array(
    'name' => 'Header',
    'id' => 'home-header-widget',
    'before_widget' => '<div class="featured-home %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<span class="featured-title">',
    'after_title' => '</span>',
));

register_sidebar(array(
    'name' => 'Sidebar',
    'id' => 'home-sidebar-widget',
    'before_widget' => '<div class="menu side %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h4 class="sidebarTitle">',
    'after_title' => '</h4>',
)); 
2
  • Which theme are you using?
    – Androliyah
    Commented Oct 12, 2012 at 17:35
  • I'm using my own. I've updated the post with the relevant code bits.
    – Scott B
    Commented Oct 12, 2012 at 20:43

1 Answer 1

0

Rearrange register_sidebar() calls in your code so the one you want to be first is registered first.

3
  • The only problem I have with that is that I want the sidebars to appear top to bottom in the widget area according to how they appear in the theme. So "header" is positioned higher than "sidebar".
    – Scott B
    Commented Oct 14, 2012 at 17:11
  • @Scott B please elaborate in your question that you would like to preserve sidebar order in admin, but change widget behavior like that.
    – Rarst
    Commented Oct 14, 2012 at 17:15
  • Thanks Rarst. I've updated the question with more detail.
    – Scott B
    Commented Oct 14, 2012 at 22:58

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.