Last active
August 29, 2015 13:55
-
-
Save robskidmore/8715546 to your computer and use it in GitHub Desktop.
Add body class based on custom taxonomy term
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function add_taxonomy_term_as_body_classes( $classes ) { | |
global $post; | |
$terms = wp_get_post_terms($post->ID, '[taxonomy]', array("fields" => "all")); | |
foreach ($terms as $class ) { | |
$classes[] = $class->slug; | |
} | |
return $classes; | |
} | |
add_filter('body_class','add_taxonomy_term_as_body_classes'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment