0
votes

Im trying to build my first WordPress theme and need a little help.

I have 4 sidebar areas setup in the footer, I would like to add a conditional statement to only show the widget area if either footer-widget-1, footer-widget-2, footer-widget-3 or footer-widget-4 sidebars are active.

I have this code:

<?php if ( is_active_sidebar( 'footer-widget-1' ) ) : ?>
<div id="footer">
<div class="container">
    <div class="col-xs-12 footer-widgets">
        <div class="col-xs-3">
            <?php dynamic_sidebar ('footer-widget-1');?>
        </div>
        <div class="col-xs-3">
            <?php dynamic_sidebar ('footer-widget-2');?>
        </div>

        <div class="col-xs-3">
            <?php dynamic_sidebar ('footer-widget-3');?>
        </div>

        <div class="col-xs-3">
            <?php dynamic_sidebar ('footer-widget-4');?>
        </div>
    </div> <!-- END FOOTER WIDGETS -->
</div> <!-- END CONTAINER -->
</div> <!-- END FOOTER -->
<?php endif; ?>

Which means the footer div will only show if footer-widget-1 has active widgets, I would like to change this so that the footer area displays if any of these sidebars have active widgets.

Help much appreiated.

1

1 Answers

2
votes

This should be quite straightforward, try adding some simple or logic to your code and check if any of the widgets are active:

<?php if ( is_active_sidebar( 'footer-widget-1' ) || is_active_sidebar( 'footer-widget-2' ) || is_active_sidebar( 'footer-widget-3' ) || is_active_sidebar( 'footer-widget-4' ) ) : ?>