0

I making a widgetized footer with three widgetized areas (footer1, footer2, footer3), The problem is that even if there's no widgets assigned to any widgetized footer area, the footer is still there with his black background! what I want is to remove the footer if there isn't any widget assigned.

1

I would use the is_active_sidebar() conditional:

<?php
if ( is_active_sidebar( 'footer' ) ) {
    ?>
    <div id="sidebar-footer">
        <?php dynamic_sidebar( 'footer' ); ?>
    </div>
    <?php
}
?>

That way, you can conditionally output the styled container itself.

0

I tried this solution but it doesn't work at all!

 if( !dynamic_sidebar('footer1') || !dynamic_sidebar('footer2') || !dynamic_sidebar('footer3') ) {
 // Do nothing
} else {
 // Display the footer
}

Thanks to Chip Bennett His solution works fine, I used it like that:

<?php if( is_active_sidebar('footer1') || is_active_sidebar('footer2') ||    is_active_sidebar('footer3')) { 
?>
<div class="footer">
</div>
<?php } ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.