Skip to content

Instantly share code, notes, and snippets.

@landru247
Last active August 29, 2015 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save landru247/9957709 to your computer and use it in GitHub Desktop.
Save landru247/9957709 to your computer and use it in GitHub Desktop.
WordPress: get list of terms - Puts a list of Terms (taxonomies) in a <ul> and does not add <a> links
<!-- if in a loop -->
<?php
$terms_as_text = strip_tags(get_the_term_list($wp_query->post->ID, 'tmc_works', '', ', ', ''));
echo $terms_as_text;
?>
<!-- or -->
<?php echo '<ul>'; ?>
<?php
$terms_as_text = wp_get_object_terms( $post->ID, 'mac_practice');
$termcount=0;
while($terms_as_text[$termcount]->name){
?>
<li>
<?php
echo $terms_as_text[$termcount]->name;
$termcount++;
?>
</li>
<?php } ?>
<?php echo '</ul>'; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment