Created
April 9, 2023 20:58
-
-
Save KittenCodes/59ee43a948e841cfac97ca916c0c705d to your computer and use it in GitHub Desktop.
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 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