Settingg active class for home, pages, and categories problem?
-
OK, I’m puzzled. I setup active classes using PHP to check if I’m on a specific page, category or sub cat. Everything works as expected accept when on the home page I’m getting an active class on the home page AND page 2?
<ul> <li <?php if(is_home()){?> class="active"<?php }?> > <a href="/" >Home</a> </li> <li <?php if (is_page('1') || in_category('1') || post_is_in_descendant_category( 1 )) { ?> class="active" <?php }?> > <a href="/page1">Page 1</a> </li> <li <?php if (is_page('2') || in_category('2') || post_is_in_descendant_category( 2 )) { ?> class="active" <?php }?> > <a href="/page2">Page2</a> </li> <li <?php if (is_page('3')){?> class="active" <?php }?> > <a href="/page3">page3</a> </li> </ul>
For some reason post_is_in_descendant_category( 2 ) is true when im on the home page?
I have no idea, any help would be awesome!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Settingg active class for home, pages, and categories problem?’ is closed to new replies.