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') ) {
// 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

  • 2
    you can give ids to your sidebars and style sidebars based on ids.Is their any problem with ids based styling ? – Ravinder Kumar May 23 '13 at 23:15

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 */

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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