Skip to content

Instantly share code, notes, and snippets.

@eliasfaical
Created March 8, 2018 20:10
Show Gist options
  • Save eliasfaical/c7eb39f0ef150681e588e3fe6860aadd to your computer and use it in GitHub Desktop.
Save eliasfaical/c7eb39f0ef150681e588e3fe6860aadd to your computer and use it in GitHub Desktop.
<?php
// Get terms for post
$terms = get_the_terms( $post->ID , 'oil' );
// Loop over each item since it's an array
if ( $terms != null ){
foreach( $terms as $term ) {
$term_link = get_term_link( $term, 'oil' );
// Print the name and URL
echo '<a href="' . $term_link . '">' . $term->name . '</a>';
// Get rid of the other data stored in the object, since it's not needed
unset($term);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment