Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
Thanks, it works like a charm :) –  Rahman Sharif Mar 2 '13 at 22:33
add comment

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 } ?>

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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