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.

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>',
)); 
share|improve this question
    
Which theme are you using? –  Aliyah Oct 12 '12 at 17:35
    
I'm using my own. I've updated the post with the relevant code bits. –  Scott B Oct 12 '12 at 20:43
add comment

1 Answer

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

share|improve this answer
    
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 Oct 14 '12 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 Oct 14 '12 at 17:15
    
Thanks Rarst. I've updated the question with more detail. –  Scott B Oct 14 '12 at 22:58
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.