If I am reading this right, all you need is a count of the active sidebars, so:
$col = 0;
if(is_active_sidebar('footer')) {
$col++;
}
if(is_active_sidebar('footer-2')) {
$col++;
}
if( is_active_sidebar('footer-3')) {
$col++;
}?>
<div class="<?php echo 'column-'.$col; ?>">
Note: I flipped the “column” class so that it begins with a letter. Numbers are not allowed as the first character. If you wanted to convert that to “one”, “two”, etc you should be able to cook that up yourself without much effort but it doesn’t seem worth the overhead to me when a simple structural change makes it unnecessary.
Related Posts:
- Programmatically add widgets to sidebars
- Loading scripts only if a particular shortcode or widget is present
- Limit number of Widgets in Sidebars
- Translate widget titles using qTranslate plugin
- How Do I Add Custom CSS To Only Certain Widgets
- Add the sidebar/widget editor to the post edit screen?
- Get sidebar parameters (before_widget, before_title, etc.) from within a widget
- $post>ID displays wrong post ID
- Video Embed in Sidebar Widget with Links to Others in Category
- Remove All Widgets from Sidebar
- Unregistering a Sidebar in Child Theme
- Add a select box to all widgets
- Problems with the sidebar args and wp_list_bookmarks
- How to avoid widgets added to sidebar on theme activation?
- Ban certain widgets from certain sidebars
- Manual display of widget
- Sidebar Widget Registration without a name, how is it assigned to new named sidebar widget?
- is_active_sidebar() Always Returns False
- How could a Widget behave differently depending on sidebar
- Is there a way to allow only certain type of widgets in the sidebars?
- Display sidebar that created in functions.php
- How to insert widget areas specific to certain pages (or posts, etc.)?
- List sidebars on a page
- dynamic_sidebar() returns false in admin section
- duplicate sidebar
- How to check if searchform.php is being included as widget?
- the_widget() and widget’s ID
- Insert Widget option into mark-up with register_sidebar
- Full width layout for custom post type pages
- Adding custom html and standard widgets to sidebar
- How to add new sidebar widget area to child theme?
- Display the id list of active widgets of same sidebar?
- How to remove a widget from the sidebar on specific page?
- Add individual tag to widget title in sidebar
- different class (css) for sidebar widgets
- How can I assign widgets from WP to appear in bbpress?
- How can I get the first section of a page 100% width, while the rest will have a sidebar? [closed]
- Can you target a widget_class in a register_sidebar?
- How to create pagination for homepage with widgetized area?
- Dynamically add content to an existing widget area
- How can I inject html after the [x]th widget inside a Sidebar? [duplicate]
- Default widgets assignment – isn’t working
- Copy Widget Settings because of changed IDs
- Programmatically add widgets to sidebars
- Override WordPress Widget CSS Classes?
- Are widgets meant to be used outside of sidebars?
- wp_get_attachment_image() not displaying post images even though wp_get_attachment_url() echo correct urls
- Show a widget as a sidebar fallback
- Dynamic Sidebar and XHTML Validity?
- Update widget form after drag-and-drop “only specific plugin”
- Recent Comments from Specific Category Widget
- Different sidebars not changing
- what is the best way to add things to a side bar
- Different widgets in sidebar on sub-children pages?
- Display posts from category in post content?
- Is there a way to use get_sidebar() when no widgets are activated?
- Multiple rows of footer widget areas
- What conditional to use for dynamic sidebar check?
- Any available action to add content before and after sidebar?
- Distinguish between different widgets of the same type
- links to Media Library content in sidebar per page
- Why is registering a sidebar for each page causing my sidebars to reset?
- How to Catch Last Widget box From Same Widget Area?
- activate custom sidebar widgets
- How can I detemine the parameters needed by the_widget()?
- widgets in footer?
- WordPress Local to Live and The Missing Widgets!
- How can I have sidebar widgets on Twenty Seventeen theme on all pages?
- My theme didn’t appear sidebar area
- How to create sidebar from “scratch”?
- Display current tag archive’s name and description in sidebar
- Need two sidebar (right and left)in Twenty Seven theme
- Sidebar widgets are over the content in mobile mode, how can I fix it? [closed]
- How to get sidebar widgets in leftsidebar template
- Add Social Media icon widget to customizer
- Loading scripts only if a particular shortcode or widget is present
- Use customizer or sidebar for header settings?
- Script in sidebar blocks other widget’s load
- Does current page contain widget or sidebar
- three sidebars showing without call
- Can I get variable into dynamic sidebar?
- Paginate recent posts widget
- $before/after_widget/title not displaying anything
- if is within sidebar [duplicate]
- how to call new widgets in sidebar in custom theme?
- How can I get the sidebar id on the current page?
- user definable sidebar per page
- Call sidebar from a template
- Show or hide custom menu widget in side bar conditionally
- Custom tabs widget don’t work in google chrome, is blocked, do not change the tabs. Why?
- Post Thumbnails on Sidebar Widgets
- Unique widget id in sidebar
- Correct way to add a block element to sidebar layout
- How to exclude a widget from showing up on a page?
- How to completely remove the sidebar? [closed]
- How can I add multiple content-editable blocks without a plug-in?
- Putting a URL, for a preview, in a side bar
- Add a twitter feed to my WordPress website
- How to tell if a dynamic sidebar is being displayed on page?
- Add custom settings to widget areas