Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KittenCodes/59ee43a948e841cfac97ca916c0c705d to your computer and use it in GitHub Desktop.
Save KittenCodes/59ee43a948e841cfac97ca916c0c705d to your computer and use it in GitHub Desktop.
<?php
// Get the terms for the current post, using the Director taxonomy
$post_terms = get_the_terms( get_the_ID(), 'director' );
// If there are terms
if ($post_terms) {
// Create an empty array to add links to
$terms_list = array();
// Loop through the list of terms
foreach ($post_terms as $post_term) {
// Add the term link to the array
$terms_list[] = "<a href=" . $term_link = get_term_link( $post_term ) . ">" . $post_term->name . "</a>";
}
// Squash the array into a comma separated list of links
$terms_output = implode(", ", $terms_list);
// Close PHP, output the list, re-open PHP
?>
<div><?php echo $terms_output;?></div>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment