Reputation: 111
Quick overview of what i am trying to do. I have a template layout that has 3 columns the left and right column are widget areas. What i would like to do is test for if both widget areas are active, one of widget areas are active, or if none are active (ie. have widget content).
Examples code:
<?php if ( is_active_sidebar( 'sidebar_1' && 'sidebar_2') ) { ?>
<div class="bothSidebarsActive"></div>
<?php } elseif ( is_active_sidebar( 'sidebar_1' || 'sidebar_2' ) { ?>
<div class="OneTheSidebarsActive"></div>
<?php } else { ?>
<div class="noneOfTheSidebarsAreActive"></div>
<?php }; ?>
I have had limited success getting the IF or ELSEIF to return true, but never all three states. Anybody know what i am doing wrong ?
Thank you for any and all assistance.
Upvotes: 0
Views: 26
Reputation: 111
Ok thanks to - BULK for the assistance the code now works, here it is in case anybody else comes across this same issue.
functional code:
<?php if ( is_active_sidebar ( 'employees_sidebar' ) && is_active_sidebar ( 'contact_sidebar' ) ) { ?>
<div class="bothSidebarsActive"></div>
<?php } elseif ( is_active_sidebar ( 'employees_sidebar' ) || is_active_sidebar ( 'contact_sidebar' ) ) { ?>
<div class="OneSidebarActive"></div>
<?php } else { ?>
<div class="noneOfTheSidebarsAreActive"></div>
<?php } ?>
Upvotes: 0
Reputation: 5685
elseif ( 'employees_sidebar' || 'contact_sidebar' )
looks like your issue to me. You should be using the is_active_sidebar
function here also. Like this:
<?php } elseif ( is_active_sidebar('employees_sidebar') || is_active_sidebar('contact_sidebar') ) { ?>
Upvotes: 2