-1

I have a nav which I would like to detect if it should an li should have a class of active or not.

I usually do this for a normal page like so:

    <li <?php if ( is_page('about')) { echo ' class="active"'; } ?>>
                            <a href="<?php bloginfo('url'); ?>/about">About</a>
                        </li>

However im 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 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>
probablybest
  • 1,403
  • 2
  • 24
  • 47

1 Answers1

0

is_taxonomy() is deprecated since version 3.0. Instead try is_tax(). You'd use it like this:

if ( is_tax( 'taxonomy-slug-here', 'illustration' ) ) {
    // Do something.
}

Ref: http://codex.wordpress.org/Function_Reference/is_tax

henrywright
  • 10,070
  • 23
  • 89
  • 150