Highlight current Wordpress category on a single page 'wp_list_categories'


/ Published in: PHP
Save to your folder(s)

Uses the 'current_category' parameter of 'wp_list_categories'. Add relevant CSS as appropriate...


Copy this code and paste it in your HTML
  1. <?php // ...for 'wp_list_categories'
  2. if(is_single()) {
  3. $category = get_the_category();
  4. $class .= $category[0]->cat_ID;
  5. }?>
  6. <?php wp_list_categories('orderby=id&child_of='.$categoryObj->category_parent.'&hide_empty=0&title_li=&use_desc_for_title=0&exclude=5&current_category='.$class); ?>

URL: http://codex.wordpress.org/Template_Tags/wp_list_categories

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.