Skip to content

Instantly share code, notes, and snippets.

@amouratoglou
Last active August 19, 2019 02:31
Show Gist options
  • Save amouratoglou/20f8153303a31497f5c797aff21c34cc to your computer and use it in GitHub Desktop.
Save amouratoglou/20f8153303a31497f5c797aff21c34cc to your computer and use it in GitHub Desktop.
Wordpress Show Taxonomy Term Title and Slug inside loop #wordpress
<?php
// Print term slug
$terms = get_the_terms( $post->ID , 'oil' );
if ( $terms != null ){
foreach( $terms as $term ) {
print $term->slug ;
unset($term);
} }
// Get term title
$terms = get_the_terms( $post->ID , 'oil' );
if ( $terms != null ){
foreach( $terms as $term ) {
print $term->name ;
unset($term);
} } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment