Skip to content

Instantly share code, notes, and snippets.

@thefuxia
Created July 24, 2010 23:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thefuxia/489088 to your computer and use it in GitHub Desktop.
Save thefuxia/489088 to your computer and use it in GitHub Desktop.
Converts post categories into CSS classes
<?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