Support » Fixing WordPress » Alternating Sidebar Widget Styles

  • Resolved eryanv


    I’d like my sidebar widgets to alternate between two styles, much like you might have two styles for table rows (one for even numbered rows, and one for odd numbered rows). Can this be done with the dynamic sidebars? If so, how?

Viewing 3 replies - 1 through 3 (of 3 total)
  • you CAN do this with my widget logic plugin

    using the widget_content filter capability. and this in your functions.php:

    add_filter(‘widget_content’, ‘make_alternating_widget_styles’);
    function make_alternating_widget_styles($content=”)
    { global $make_alt_ws;
    return preg_replace(‘/(class=”widget )/’, “$1 widget_${make_alt_ws} “, $content);

    so if your widgets are usually class=”widget …” this will add in “widget_style_a”/”widget_style_b” into that class definition.

    I was hoping something would be built into core, but this works too.


    Having it in the functions.php file is a much better option as it won’t be saved over when the core is updated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Alternating Sidebar Widget Styles’ is closed to new replies.