I'd like to add a background color to my wordpress widgets. I'm just not sure which wordpress file I need to add the tags to. Is there a tutorial that someone might have come across somewhere on the net that would walk me through the process? Thank you
hi, probably the easiest way is to add a div around each widget. In your functions.php file where u see: if ( function_exists('register_sidebar') ) register_sidebar(array( 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); Code (markup): replace it with: if ( function_exists('register_sidebar') ) register_sidebar(array( 'before_widget' => '<div class="widgy"><li id="%1$s" class="widget %2$s">', 'after_widget' => '</li></div>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); Code (markup): and simply style the widgy class with css: .widgy { background: #XXXXXX; }
Thanks for your reply. I've edited this post....I got it to work with the first sidebar. The second sidebar doesn't show up. I'm assuming it's because my functions.php has the line register_sidebars(2); but I'm not sure where or how I would add that to the code you provided. Below is my original functions.php <?php if ( function_exists('register_sidebar') ) register_sidebars(2); ?>.
heya, just copy a new side bar and give them names: if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar 1', 'before_widget' => '<div class="widgy"><li id="%1$s" class="widget %2$s">', 'after_widget' => '</li></div>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar 2', 'before_widget' => '<div class="widgy"><li id="%1$s" class="widget %2$s">', 'after_widget' => '</li></div>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); PHP: then wherever you want your sidebar just put this in <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("sidebar name") ) : ?> No widgets stuff goes here <?php endif; ?> PHP: just change 'sidebar name' of the sidebar u want e.g: 'Sidebar 2' both sidebars can have widgets added from the Presentation->Widgets menu in wordpress admin