quagliato
10/24/2013 - 6:15 PM

Print categories of a post, with links

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);
  }
?>