Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8509019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:19:10+00:00 2026-06-11T03:19:10+00:00

im building wordpress theme and i created 4 sidebars to use on footer, now

  • 0

im building wordpress theme and i created 4 sidebars to use on footer, now i need to have dynamic width of those 4 sidebars depending of how many of them are active.

So for example if i have only footer1 sidebar active, his width should be 100%

If i have footer1 and footer2, or footer1 and footer4, or footer2 and footer3 active they should be 50%,

If i have 3 of them active 33%

And if i have all 4 of them each one should be 25% width.

Just to say again, these are not active widgets in one sidebar, all 4 of them are separated sidebars.

I think this could be done with “switch” and “case” php functions, or with “if” but i don’t know how to count them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:19:12+00:00Added an answer on June 11, 2026 at 3:19 am

    It looks like you could use wp_get_sidebars_widgets, which returns an associative array of sidebars and their widgets.

    With that in mind you could do something like this to set the width of the sidebar. You will need to create the CSS classes to match the names I’ve chosen to specify the width.

    $sidebars = wp_get_sidebars_widgets();
    $count = count($sidebars['sidebar-area-name']);
    $class_name = 'widget_count-' . $count;
    
    // an alternative to a class would be
    // $width = round(100 / $count);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have jQuery for a WordPress theme I'm building. I've given up for now
i'm building a wordpress webpage based on the Skeleton Wordpress theme. I have 2
I am building a wordpress theme I want to have the next and previous
I'm building a Wordpress theme, and I have these snippets in my style.css: #content
I am building a custom wordpress theme and have a slideshow on the front
I am building a custom WordPress theme and need to add descriptions to my
I am building a WordPress theme for a small startup. They want to have
I'm currently building a WordPress theme that I would like to have a header
im building off the wordpress plaintxt sandbox theme, and what i have i a
I'm building a WordPress theme which will soon need jQuery UI (just core and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.