Skip to content

Instantly share code, notes, and snippets.

@mahfuzul
Created January 21, 2016 08:26
Show Gist options
  • Save mahfuzul/09a7f2c6f6be4db4bac4 to your computer and use it in GitHub Desktop.
Save mahfuzul/09a7f2c6f6be4db4bac4 to your computer and use it in GitHub Desktop.
Print WordPress Taxonomy Terms as list
<?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