I have a nav which I would like to detect if an li should have a class of active or not.
I usually do this for a normal page like this:
<li <?php if ( is_page('about')) { echo ' class="active"'; } ?>>
<a href="<?php bloginfo('url'); ?>/about">About</a>
</li>
However I'm doing this on a taxonomy page and I would like to detect the name of the taxonomy term. So I have 4 terms, design
, illustration
, motion
and photography
.
How would I go about adding a class to the li of the active taxonomy term?
Here is what I have so far but its wrong:
<li <?php if ( is_taxonomy('illustration')) { echo ' class="active"'; } ?>><a href="<?php echo site_url(); ?> /talcat/illustration">Illustration</a></li>
Update:
I have changed is_taxonomy
to is_tax
and then defining my taxonomy name and term. However this still isnt working. Here is my update coded:
<li <?php if ( is_tax( $Talcat, $illustration)) { echo ' class="active"'; } ?>>