Last active
May 6, 2018 21:53
-
-
Save anatol06/da81e1d5d4be143f3397009d38828d8e to your computer and use it in GitHub Desktop.
Get the list of categories to which the article belongs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Get the list of categories to which the article belongs | |
$categories = get_the_category(); | |
$separator = ", "; | |
$output = ''; | |
if($categories) { | |
foreach($categories as $category) { | |
$output .= '<a href="'. | |
get_category_link($category->term_id).'">'. | |
$category->cat_name .'</a>'.$separator; | |
// $output .= $category->cat_name . $separator; | |
} | |
} | |
echo trim($output, $separator); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment