Reputation: 398
I have this code:
<?php
//list terms in a given taxonomy (useful as a widget for twentyten)
$taxonomy = 'advice-cat';
$tax_terms = get_terms($taxonomy);
?>
<ul>
<?php
foreach ($tax_terms as $tax_term) {
echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>';
}
?>
</ul>
it display the list of category with permalink. so I want if I click one of the category in the list the list I click must highlight so visitors identify that they are in that specific category.
Upvotes: 1
Views: 264
Reputation: 549
Have you tried the wp_list_categories() function?
From the Codex: http://codex.wordpress.org/Template_Tags/wp_list_categories
Another option is to run a walker function to ouput a menu:
https://wordpress.stackexchange.com/questions/115526/add-class-to-items-in-wp-list-categories
Upvotes: 1