Skip to content

Instantly share code, notes, and snippets.

@leanda
Created April 3, 2013 08:51
Show Gist options
  • Save leanda/5299565 to your computer and use it in GitHub Desktop.
Save leanda/5299565 to your computer and use it in GitHub Desktop.
WordPress: Output for the post's categories, building on get_the_category() adds category slug as a class.
<?php $sep = '';
foreach((get_the_category()) as $cat) {
echo $sep . '<a href="' . get_category_link($cat->term_id) . '" class="cat-' . $cat->slug . '" title="View all posts in '. esc_attr($cat->name) . '">' . $cat->cat_name . '</a>';
$sep = ', ';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment