WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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
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


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.