Last active
May 7, 2016 13:48
-
-
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); ?>
This file contains 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 | |
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 " "; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just updated name of function