Skip to content

Instantly share code, notes, and snippets.

@quagliato
Created October 24, 2013 18:15
Show Gist options
  • Save quagliato/7142312 to your computer and use it in GitHub Desktop.
Save quagliato/7142312 to your computer and use it in GitHub Desktop.
Print categories of a post, with links
<?php
$cats = get_the_category(get_the_id());
$separator = ', ';
$output = '';
foreach($cats as $cat){
$output =
'<a href="'.
get_category_link($cat->term_id).
'" title="'.
esc_attr(sprintf(__("Veja todos os posts em %s"), $cat->name)).
'">'.
$cat->name.
'</a>'.
$separator;
echo trim($output, $separator);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment