- Name:
<?php $terms = get_the_terms($post->ID, 'projects_category');foreach($terms as $term){echo $term->name;} ?>
- Name with href
<?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); } } ?>
Post a Comment
Post a Comment