Support » Fixing WordPress » Collapse Widget Area When Empty

  • I have created 4 custom widget pockets in my footer (_s) and cannot get the space to collapse when all of them are empty. It looks bad and I suspect if I can add the div tag and class before, and the </div> tag after with the php in functions, there must be a way to have it check that all four are empty (have that piece below) and then clear or remove the container div and collapse the space it now fills. I found this code posted in the forum from 5 years ago but nothing more. This makes sense but I can’t figure out the rest of the php, the html and css that would make it all work together.

    if ( ! is_active_sidebar( ‘first-footer-widget-area’ )
    && ! is_active_sidebar( ‘second-footer-widget-area’ )
    && ! is_active_sidebar( ‘third-footer-widget-area’ )
    && ! is_active_sidebar( ‘fourth-footer-widget-area’ )

    Any help would be appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • please post the code of footer.php (or in what ever file you call the widgets);

    generally, have a look into the code of Twenty Eleven to see how they handle the footer widgets…

    Heres the basic code in footer, it’s registered in functions and the CSS is working.

    <div class=”widget-container-box”>
    <div class=”each-widget”>
    if (!function_exists( ‘dynamic_sidebar’) || !dynamic_sidebar(‘Custom Widget 1’)) : ?>
    <?php endif;
    <!– …there are four widgets total.–>

    Thanks for the suggestion. I can usually figure things out with an example so I’m pulling a copy of 2011 right now!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Collapse Widget Area When Empty’ is closed to new replies.