in_category is returning true on homepage (index.php)
-
I am testing out a site and have run into a strange issue. Basically, I want my navigation list to give an ID of “current” if on a Portfolio page or a Portfolio category post (catID = 3 in this case). My code for my navigation is as follows:
<li<?php if (is_home()) { echo " id=\"current\""; }?>><a href="/">home</a></li> <li<?php if (is_page('about')) { echo " id=\"current\""; }?>><a href="/about/">about</a></li> <li<?php if (is_page('portfolio')||in_category('3')) { echo " id=\"current\""; }?>><a href="/portfolio/">portfolio</a></li> <li<?php if (is_page('contact')) { echo " id=\"current\""; }?>><a href="/contact/">contact</a></li>
All works well on both the Portfolio page and the Portfolio category post, however when I browse back to my homepage (index.php), my “Home” and “Portfolio” navigation links both have an ID of “current”. I’m not sure why the homepage is returning true for in_category(‘3’), but it’s frustrating me quite a bit. In-fact my index.php file only has get_header(); and get_footer(); so far with no content. So what can it be?
Any insight or help would be appreciated, thanks!!
- The topic ‘in_category is returning true on homepage (index.php)’ is closed to new replies.