Created
July 24, 2010 23:26
-
-
Save thefuxia/489088 to your computer and use it in GitHub Desktop.
Converts post categories into CSS classes
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
<?php | |
function categories_to_classes() | |
{ | |
$out = ''; | |
$cats = get_the_category(); | |
foreach ( $cats as $cat_object ) | |
{ | |
$out .= $cat_object->slug . ' '; | |
} | |
return trim($out); | |
} | |
// Usage | |
?> | |
<div class="<?php | |
print categories_to_classes(); | |
?>"> content </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment