[wp-testers] Body classes don't get added on custom taxonomy pages
Ben Huson
ben at thewhiteroom.net
Fri Jun 18 21:22:51 UTC 2010
It seems that if you add a cutsom taxonomy it doesn't automatically
add classes to the HTML body tag like it does with in-built
categories.
If fixed by adding this to my functions.php file, but should it happen
automatically in core?
function taxonomy_body_class( $classes ) {
if ( is_tax() ) {
$tax = get_query_var( 'taxonomy' );
$term = $tax . '-' . get_query_var( 'term' );
$classes = array_merge( $classes, array( $tax, $term ) );
}
return $classes;
}
add_filter( 'body_class', 'taxonomy_body_class' );
- Ben
More information about the wp-testers
mailing list