How to specify the “Main Sidebar” for a theme

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).

Read More

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>',
)); 

Related posts

Leave a Reply

1 comment