condiitonal `if` is not working right
-
I have this on my
header.php
<?php if ( is_home() || is_front_page() ) { ?> <?php } elseif ( is_category_or_sub('gamenews') || has_category('gamenews') ) { ?> <ul id="sections"> <li><!-- stuff X here --></li> </ul><!-- #sections --> <?php } elseif ( is_category_or_sub('hobbynews') || has_category('hobbynews') ) { ?> <ul id="sections"> <li><!-- stuff Y here --></li> </ul><!-- #sections --> <?php } ?>
It is supposed to show different stuff on different page. If it’s on homepage (is_home), it shows nothing. If it’s on category gamenews or its children (is_category_or_sub, it’s a custom function), it shows stuff X. If it’s on category hobbynews or its children, it shows stuff Y.
The problem lies on the last
elseif
(the one on hobbynews). It won’t show the stuff Y as I expect it to be. Instead, it shows stuff X which is supposed to only appear on gamenews category.Why is it happening?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘condiitonal `if` is not working right’ is closed to new replies.