Pages are in the default Category?
-
I’m using WP as a CMS for a site that’s not terribly bloggish, so far, everything’s more than I could hope for. However:
My navigation menu’s links have an “active” state that displays when you’re in/on whatever category/page of the site.
All’s working well as far as triggering the active class EXCEPT for the fact that the News link (links to a category archive) still gets an active class when you’re on one of the two pages (About/Contact), meaning two links at once have the active class. A different category’s link (which I’ve not included in the code below because it’s way messier to look at) works just fine, and the News category link doesn’t go “active” when you’re in it.
I have a feeling that it’s because I’m using the default category for News (I renamed Uncategorized to News). The Pages are somehow in the default category (category #1), which is why the conditional statement for News is true even when in the pages?
How can I make it stop?? I really don’t want to make News the non-default category. The user I’ll be handing this off to is highly unlikely to remember to select a category when posting new News items.
<div id="sidebar"> <ul> <li><a href="<?php echo get_option('home'); ?>" class="nav"><img src="./images/main.jpg" alt="Main" /></a></li> <li><a href="./news/" class="nav<?php if (in_category('1')){echo ' active';} ?>"><img src="./images/news.jpg" alt="News" /></a></li> <li><a href="./about/" class="nav<?php if (is_page('about')){echo ' active';} ?>"><img src="./images/about.jpg" alt="About" /></a></li> <li><a href="./contact/" class="nav<?php if (is_page('contact')){echo ' active';} ?>"><img src="./images/contact.jpg" alt="Contact" /></a></li> </ul> </div>
Is there another way I can call the active class for the News/default category so that it’s not affected by pages? I’d like for it to be active regardless of whether it’s the archive or a single page in the News category, or I’d switch to that more specific call.
Has anyone come across this before?
- The topic ‘Pages are in the default Category?’ is closed to new replies.