admin管理员组文章数量:1334885
Is there a way to draw the categories listing and highlight the current category being viewed?
In addition, it would be great to highlight the current category if a post or page that's assigned to it is being viewed.
Any help much appreciated...
Here's my current code (I'm excluding the default "uncategorized" category)...
echo "<div class='menu top'><ul>";
$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
$cat_args['title_li'] = '';
$cat_args['exclude_tree'] = 1;
wp_list_categories(apply_filters('widget_categories_args', $cat_args));
echo "</ul></div>";
Is there a way to draw the categories listing and highlight the current category being viewed?
In addition, it would be great to highlight the current category if a post or page that's assigned to it is being viewed.
Any help much appreciated...
Here's my current code (I'm excluding the default "uncategorized" category)...
echo "<div class='menu top'><ul>";
$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
$cat_args['title_li'] = '';
$cat_args['exclude_tree'] = 1;
wp_list_categories(apply_filters('widget_categories_args', $cat_args));
echo "</ul></div>";
Share
Improve this question
asked Aug 24, 2010 at 17:20
Scott BScott B
5,69614 gold badges94 silver badges148 bronze badges
2
- Hey @Scott B: I see you'd only accepted 1 of 4 answers. Just a tip, if you find someone's answer to your question is good please do mark it as the best answer and give a vote up to anyone else who provides good input. That'll bump up their reputation and given them some recognition for their efforts. – MikeSchinkel Commented Aug 25, 2010 at 22:39
- Thanks, I just started posting questions a few days ago. I'm evaluating the answers. It does not mean an answer won't be selected once I have more time to review them. – Scott B Commented Aug 26, 2010 at 11:41
2 Answers
Reset to default 2The Wordpress Codex for the wp_list_categories tag is actually pretty helpful here - Wordpress is already assigning a class to the < li > tag of the current category.
At that point you just need to add an entry to your theme's .css file to apply whatever highlighting you want to that class.
For instance:
li.current-cat {
background: #CCC; }
Should give you a nice grey background.
My first inclination is that you'd need to somehow apply a different class to the "current" category and then use CSS to highlight it. Hopefully that's a start.
本文标签: Categories Listing with quotselectedquot category highlighted
版权声明:本文标题:Categories Listing with "selected" category highlighted 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742375189a2463020.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论