• Resolved microcipcip

    (@microcipcip)


    Hi, I’m making a wordpress highlight tab menu, here is the code:

    <ul id="navtabs">
    <li<?php if ( is_home() ) { echo ' class="current"'; } ?>><a href="<?php bloginfo('url'); ?>">Home</a></li>
    <li<?php if ( is_category('1') ) { echo ' class="current"'; } ?>><a href="?cat=1">About</a></li>
    <li<?php if ( is_category('2') ) { echo ' class="current"'; } ?>><a href="?cat=2">Portfolio</a></li>
    <li<?php if ( is_category('3') ) { echo ' class="current"'; } ?>><a href="?cat=3">Tutorials</a></li>
    </ul>

    The Highlight menu works only in the main category, if I click inside a post (for example a post nested inside portfolio) I don’t see any tab highligthed. I have already tryed to add || is_single() in all link, but it doesn’t work.
    Does exist a way to keep highligthed Portfolio when I am inside a post nested in that Category?

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try in_category() instead of if_category().

    Thread Starter microcipcip

    (@microcipcip)

    It works!
    Thank you so much!

    I post here the final code if somebody has to do the same.

    <ul id="navtabs">
    <li<?php if ( in_category('1') ) { echo ' class="current"'; } ?>><a href="<?php bloginfo('url'); ?>"><span>Home</span></a></li>
    <li<?php if ( in_category('9') ) { echo ' class="current"'; } ?>><a href="?cat=9"><span>Portfolio</span></a></li>
    <li<?php if ( in_category('6') ) { echo ' class="current"'; } ?>><a href="?cat=6"><span>Tutorials</span></a></li>
    <li<?php if ( in_category('8') ) { echo ' class="current"'; } ?>><a href="?cat=8"><span>Chi Siamo</span></a></li>
    </ul>
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Highlight Tab Menu’ is closed to new replies.