[英]Adding class “current_page_item” for custom post type category list(note: the category is belong in custom taxonomy)
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.
因此,如果我单击列表中的一个类别,我想单击的列表必须突出显示,以便访问者识别出他们属于该特定类别。
Have you tried the wp_list_categories() function? 您是否尝试过wp_list_categories()函数?
From the Codex: http://codex.wordpress.org/Template_Tags/wp_list_categories 来自法典: http : //codex.wordpress.org/Template_Tags/wp_list_categories
Another option is to run a walker function to ouput a menu: 另一种选择是运行walker函数以输出菜单:
https://wordpress.stackexchange.com/questions/115526/add-class-to-items-in-wp-list-categories https://wordpress.stackexchange.com/questions/115526/add-class-to-items-in-wp-list-categories
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.