Support » Themes and Templates » Flexible widths for horizontally displayed widgets

  • Hi –

    I’m customizing a theme with a “sidebar” along the bottom of the page, and I want the widgets there to have flexible widths depending on how many widgets are published to the sidebar. So if there are 4 widgets, the before_widget output will be <div style=”width: 25%”>, if there are 3 widgets <div style=”width: 25%”>, etc. Of course, this would be very easy to to with tables, but tables are the devil now, right?

    So I want to do something like this:

    $columns = $number_of_widgets;
    $width = 100/$columns;
    'before_widget' => '<div class="bottom-module" style="width: '.$width.'%">',

    etc, etc.

    The only question is, how do I populate $number_of_widgets for the specific sidebar (theme uses multiple sidebars)?

    Thanks –


  • The topic ‘Flexible widths for horizontally displayed widgets’ is closed to new replies.