I've got a custom taxonomy called trailer_type
with terms long
and short
. When visiting my_site/trailers/short
(a page powered by template taxonomy-trailer_type.php
) I display my taxonomy terms this way:
$terms = get_terms( 'trailer_type' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
echo '<ul>';
foreach ( $terms as $term ) {
echo '<li><a href="' . get_term_link( $term ) . '" title="' . sprintf( __( 'View all post filed under %s', 'my_localization_domain' ), $term->name ) . '">' . $term->name . '</a></li>';
}
echo '</ul>';
}
Works well but is there a simple way to add a "current" class? For example if I'm on the "long" page, I'd need "long" to have "current" class in this menu.