Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save moafzalmulla/78eb19eaff8a18c49ce6c748bc0d2bf3 to your computer and use it in GitHub Desktop.
Save moafzalmulla/78eb19eaff8a18c49ce6c748bc0d2bf3 to your computer and use it in GitHub Desktop.
Below is a function that will sit in functions.php. In order to call it use <?php $tax="NameOfTaxonomy"; renderTaxonomySlug($tax); ?>
<?php
function renderTaxonomySlug($tax){
$terms = get_the_terms( $post->ID, $tax );
if ( !empty( $terms ) ){
// get the first term
$term = array_shift( $terms );
//echo $term->slug;
}
$taxonomy=$tax;
$terms = get_the_terms( $post->ID , $taxonomy );
foreach ( $terms as $term ){
$term_link = get_term_link( $term, $taxonomy );
// for name
// echo $term->name;
//for slug
echo $term->slug;
echo " ";
}
}
?>
@moafzalmulla
Copy link
Author

Just updated name of function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment