Display post categories

352

Last updated

Added

Informations

This code loop on the post categories that is the default WordPress taxonomy. In this snippet, we get the category title with echo $cat->name and the category link with echo get_category_link($cat->term_id).

Code

<?php foreach (get_the_category() as $cat) : ?>
 
  <?php echo $cat->name; ?>
  <?php echo get_category_link($cat->term_id); ?>
 
<?php endforeach; ?>

Contribute to this page

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *


name; ?> term_id); ?>