有几种方法可以实现这一点。
Using get_the_terms:
$args = array( \'post_type\' => \'movies\', \'posts_per_page\' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
the_title();
$terms = get_the_terms( get_the_ID(), \'genre\' );
if ( is_array( $terms ) ) {
//Manipulate array of WP_Term objects
}
?>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
using get_the_term_list:
$args = array( \'post_type\' => \'movies\', \'posts_per_page\' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
the_title();
echo get_the_term_list( get_the_ID(), \'genre\' );
?>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?php endwhile; ?>