0

I found a code in my sidebar-content-bottom.php in the theme itself that I don't really understand.

if ( ! is_active_sidebar( 'sidebar-2' ) && ! is_active_sidebar( 'sidebar-3' ) ) {
return;}  

I know that both conditions must be true that the if function activates

return;

But what does it return then? Two times true on the page?

3

It doesn't return anything, it just jumps back out of the function.

That's basically "If this is neither sidebar-2 nor sidebar-3, don't continue in this function".

  • So is my assumption right that when this code exists in my php file: <?php if ( ! is_active_sidebar( 'sidebar-2' ) && ! is_active_sidebar( 'sidebar-3' ) ) { return;} ?> <aside>....</aside> That the html function after the if function "<aside>"is uneffected and I could just delete the if statement because it just does nothing?! – Martin Feb 7 '18 at 11:07
  • No, or rather: not necessarily. As long as either of those two sidebars are active (that is: contain widgets), the function will execute as if those lines weren't there at all. If both sidebars are inactive, however, the code following that condition will not execute. – janh Feb 7 '18 at 11:58
  • @Martin It sounds like your theme is not outputting the aside element if neither sidebar 2 or 3 has widgets in it. – Jacob Peattie Feb 7 '18 at 12:23
  • It doesn't affect anything on my page when I delete the if function. That's why I was wondering about the function and what it does. In both cases everything worked fine. My question is therefore answered. Thanks guys!!! – Martin Feb 7 '18 at 12:33
  • Probably because you have widgets in sidebars 2 & 3. If you remove them it will behave differently. It's not doing nothing – Jacob Peattie Feb 7 '18 at 13:07

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.