Ok, I'm using the following code for up to 6 widgets in a sidebar
function s57d_sidebar1_params($params) {
$sidebar_id = $params[0]['id'];
if ( $sidebar_id == 'sidebar-1' ) {
$total_widgets = wp_get_sidebars_widgets();
$sidebar_widgets = count($total_widgets[$sidebar_id]);
$params[0]['before_widget'] = str_replace('class="', 'class="span' . floor(36 / $sidebar_widgets) . ' ', $params[0]['before_widget']);
}
return $params;
}
add_filter('dynamic_sidebar_params','s57d_sidebar1_params');
The resulting code when there are widgets in the sidebar displays like:
<section id="text-2" class="span6 widget widget_text">
<div class="span6 widget-wrap">
<h4 class="widget-title widgettitle">Text 1</h4>
<div class="textwidget">Text 1</div>
</div>
</section>
The class is being assigned to the section and then again to the div. I don't want the div to also get the class. What is wrong with the code?
Thanks