以user3208代码为例,我添加了一些代码,将URL添加到术语中。希望这能帮助别人。
<?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); } } ?>