Skip to content

Instantly share code, notes, and snippets.

@ChrisLTD
Created June 30, 2013 15:23
Show Gist options
  • Save ChrisLTD/5895564 to your computer and use it in GitHub Desktop.
Save ChrisLTD/5895564 to your computer and use it in GitHub Desktop.
Wordpress: Add custom taxonomy terms to body class
<?php
// Add custom taxonomy terms to body class
function section_taxonomy_in_body_class( $classes ){
if( is_singular() )
{
global $post;
$custom_terms = get_the_terms($post->ID, 'subsite');
if ($custom_terms) {
foreach ($custom_terms as $custom_term) {
$classes[] = 'section_' . $custom_term->slug;
}
}
}
return $classes;
}
add_filter( 'body_class', 'section_taxonomy_in_body_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment