wp_list_categories: highlight current category when viewing single post (v2)
-
Hello,
I’m reopening this post to see if anyone can help me out with this.
I wanted to adapt this sidebar generating code so that it marks only the current post’s parent and child category with a css current class.As it is now it marks the parent category of the post and all the child categories used within that parent and I only want the current one.
Here’s the code:
<?php $catsy = get_the_category(); $myCat = $catsy[0]->cat_ID; $CatwCount = wp_list_categories('hierarchical=1&use_desc_for_title=0&orderby=name&title_li=&show_count=1&echo=0&depth=2¤t_category='.$myCat); $CatwCount = ereg_replace(' \(([0-9]+)\)', ' <span class="count">[\\1]</span>', $CatwCount); echo $CatwCount; ?>
[Please post code snippets between backticks or use the code button.]
Can anyone help me out?
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘wp_list_categories: highlight current category when viewing single post (v2)’ is closed to new replies.