lundi 27 septembre 2021

Nested If else statements used in a WordPress template isn't working

I'm not sure what is wrong with the nested conditions below. The else block never seems to get executed even when the image variable is not set(hero image being absent). Please help me find the problem with it.

<?php
if ( is_singular() || is_page() ):
if( have_rows('hero') ): while( have_rows('hero') ): the_row();
if( have_rows('hero_-_background_options') ): while( have_rows('hero_-_background_options') ): the_row();
$image = get_sub_field('background_-_image');
if($image):
?>
.default-hero .col .hero-bkg {
    display:none;
}
<?php  endif; endwhile; endif; endwhile; else: ?>
.default-hero.relative.bg-grey-light {
  display: none;
}
<?php endif; endif; ?>

Aucun commentaire:

Enregistrer un commentaire