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.

Ok so i added a second sidebar to my site, only problem is styling the widgets.

here is the code i am using in my functions.php file

// Widgets plugin: intializes the plugin after the widgets above have passed snuff
function wpbx_widgets_init() {
if ( !function_exists('register_sidebars') ) {
    return;
}
// Formats the theme widgets, adding readability-improving whitespace
$p = array(
    'before_widget'  =>   '<li id="%1$s" class="widget %2$s">',
    'after_widget'   =>   "</li>\n",
    'before_title'   =>   '<h3 class="widget-title">',
    'after_title'    =>   "</h3>\n"
);

register_sidebars( 2, $p );
}

I just don't know how to style the second sidebar widget, how do i do this?

I want to use the same code but different class titles

share|improve this question
2  
you can give ids to your sidebars and style sidebars based on ids.Is their any problem with ids based styling ? –  Ravs May 23 '13 at 23:15

1 Answer 1

up vote 2 down vote accepted

Per the register_sidebars() Codex page, the CSS ID of the sidebars gets incremented by default. In other words, if you're not explicitly setting the id array value -- and in your code sample above, you aren't -- you would end up with sidebars with CSS IDs of sidebar and sidebar-2. You can then style them differently in your CSS file (be it style.css or a custom one that you've added):

#sidebar {
    /* Styles */
}

#sidebar-2 {
    /* Styles for the 2nd sidebar */
}
share|improve this answer

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.