0

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

  • Thanks, at least I was able to style the section, leaving the css in place. – Louise Jul 18 '14 at 13:12
0

While this doesn't answer your specific question, it may provide a solution for you. With a proper CSS selector, you can target a DIV of class "span6" with rules that are separate from a SECTION of class "span6".

In your CSS, write your selectors like this:

div.span6 { rules; rules }
section.span6 { differentrules; }

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.