Skip to content

Instantly share code, notes, and snippets.



Created Aug 24, 2011
What would you like to do?
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
You can’t perform that action at this time.