Created
January 21, 2016 08:26
-
-
Save mahfuzul/09a7f2c6f6be4db4bac4 to your computer and use it in GitHub Desktop.
Print WordPress Taxonomy Terms as list
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 | |
/** | |
* Print WordPress Taxonomy Terms as list | |
* @param [type] $terms_array [description] | |
* @param [type] $first_item [description] | |
* @return [type] [description] | |
*/ | |
function print_terms($terms_array, &$first_item) { | |
if(!$terms_array || count($terms_array) < 1) return; | |
foreach($terms_array as $term) { | |
if(!$first_item) { echo ", "; } | |
else { $first_item = false; } | |
echo '<a href="'.get_term_link($term->term_id).'">' . $term->name . '</a>'; | |
} | |
} | |
// Call | |
$first_item = true; | |
print_terms( get_the_terms(get_the_ID(), 'post_tag' ), $first_item ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment