Created
October 3, 2012 13:50
-
-
Save remkus/3827005 to your computer and use it in GitHub Desktop.
Add category to bodyclass
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 | |
| add_filter( 'body_class', 'fst_category_id_class' ); | |
| /** | |
| * This function add the category name to the bodyclass. | |
| * | |
| * @access public | |
| * @author Remkus de Vries | |
| * @param mixed $classes | |
| * @return void | |
| */ | |
| function fst_category_id_class( $classes ) { | |
| global $post; | |
| foreach( ( get_the_category( $post->ID ) ) as $category ) | |
| $classes[] = $category->category_nicename; | |
| return $classes; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment