Created
March 22, 2013 03:29
-
-
Save spencejs/5218739 to your computer and use it in GitHub Desktop.
Add Categories For a Post As Class Names On The Body Tag - Wordpress
This file contains 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
// add category nicenames in body and post class | |
function category_id_class($classes) { | |
global $post; | |
foreach((get_the_category($post->ID)) as $category) | |
$classes[] = $category->category_nicename; | |
return $classes; | |
} | |
add_filter('post_class', 'category_id_class'); | |
add_filter('body_class', 'category_id_class'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment