Skip to content

Instantly share code, notes, and snippets.

@bueltge
Created August 24, 2011 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bueltge/1168439 to your computer and use it in GitHub Desktop.
Save bueltge/1168439 to your computer and use it in GitHub Desktop.
Adds classes for custom taxonomies to body_class()
function fb_add_body_class( $class ) {
if ( ! is_tax() )
return $class;
$tax = get_query_var( 'taxonomy' );
$term = $tax . '-' . get_query_var( 'term' );
$class = array_merge( $classes, array( 'taxonomy-archive', $tax, $term ) );
return $class;
}
add_filter( 'body_class', 'fb_add_body_class' ); // or post_class as hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment