I'm creating a theme for my website that is WordPress based. I needed a little help like me no expert on php. My problem is much like this:

I've got a side bar div which again there has 4 sidebars:

 <div id="jp-double-bar" class="equal">
    <?php if ( is_active_sidebar( 'double-top' ) ) : ?>
    <div class="jp-double-top">
        <?php dynamic_sidebar( 'double-top' ); ?>
    <?php endif; ?>
    <div class="double-middle">
        <?php if ( is_active_sidebar( 'middle-2' ) ) : ?>
        <div class="jp-middle-2 equalmiddle">
            <?php dynamic_sidebar( 'middle-2' ); ?>
        <?php endif; ?>
        <?php if ( is_active_sidebar( 'middle-1' ) ) : ?>
        <div class="jp-middle-1 equalmiddle">
            <?php dynamic_sidebar( 'middle-1' ); ?>
        <?php endif; ?>
    <?php if ( is_active_sidebar( 'double-bottom' ) ) : ?>
    <div class="jp-double-bottom">
        <?php dynamic_sidebar( 'double-bottom' ); ?>
    <?php endif; ?>

Here my problem is when I don't publish any icons most of the sidebars, still the outer <div id="jp-double-bar"> turns up.

My real question is....... The way you are wrapping for individual sidebar by having an <?php if ():?> statement, it is possible to method to wrap the primary outer div with 4 if claims.

Like if there's no widget released most of the 4 sidebars then your primary outer div shouldn't display whatsoever.

Kindly help.


It appears you need to be utilising the wp_get_sidebars api call to retrieve the bars. Check and find out if the includes a period of zero (empty).

Or simply use and claims

if (is_active_sidebar( 'double-bottom' ) && is_active_sidebar('') && ...) {}