I have a custom taxonomy called type
. Type has the following options:
I've created a draggable element (in Visual Composer) which will show these tags. Because of this, the draggable element is not part of archive-resources.php
, so I can't run it through a loop.
What I'm trying to do is:
get_the_ID()
.type
that is assigned that blog post.However, currently, all three type
tags are displaying. Where am I going wrong?
$blogpostID = get_the_ID();
$termType = get_terms('type');
$output = '';
foreach ( $termType as $termT ) {
echo $output . '<a href="'.get_term_link($termT).'">'.$termT->name.'</a>';
}
Ok, Do it this way :
<?php
$terms = get_the_terms( $post->ID , 'type' );
$output = '';
if ( $terms != null ){
foreach ( $terms as $term ) {
echo $output . '<a href="'.get_term_link($term).'">'.$term->name.'</a>';
}
}