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>';
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.