我有这样的代码:
<?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>
显示具有永久链接的类别列表。所以我想如果我点击列表中的一个类别我点击列表必须突出显示这样访问者就能识别出他们是在那个特定的类别
您是否尝试过wp_list_categories()函数?
取自法典:http://codex.wordpress.org/Template_Tags/wp_list_categories
另一个选项是运行一个walker函数来输出一个菜单:
https://wordpress.stackexchange.com/questions/115526/add-class-to-items-in-wp-list-categories