Created
March 22, 2020 10:20
-
-
Save mennwebs/dd247e1f3af4364df0b3b848edaf4cc3 to your computer and use it in GitHub Desktop.
Add Category Name to body_class
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
| /* Add Category Name to body_class */ | |
| add_filter('body_class','moss_add_category_to_single'); | |
| function moss_add_category_to_single($classes) { | |
| if (is_single() ) { | |
| global $post; | |
| foreach((get_the_category($post->ID)) as $category) { | |
| $classes[] = 'category-' . $category->category_nicename; | |
| } | |
| } | |
| return $classes; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment