Skip to content

Instantly share code, notes, and snippets.

@diegogangl
Created April 10, 2012 13:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diegogangl/2351388 to your computer and use it in GitHub Desktop.
Save diegogangl/2351388 to your computer and use it in GitHub Desktop.
[Wordpress 3.3] I've found that wp_list_categories doesn't highlight the current category if it's a taxonomy term (and you're in a taxonomy archive), this little snippet fixes that.
<?php
// Get the term id first
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$currentTerm = $term->term_taxonomy_id;
// This is how you'd use it in your template
wp_list_categories( array(
'taxonomy' => 'YOUR_TAXONOMY',
'current_category' => ( isset($currentTerm) ) ? $currentTerm : null
));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment