如果要输出/打印术语名称,请在循环中查看:https://developer.wordpress.org/reference/functions/get_the_terms/
$terms = get_the_terms( get_the_ID(), \'pwb-brand\' );
您需要在循环中输出类似的内容:
<?php
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
$terms = get_the_terms( get_the_ID(), \'pwb-brand\' );
if ( $terms && ! is_wp_error( $terms ) ) :
$brands = array();
foreach ( $terms as $term ) {
$brands[] = $term->name;
}
$on_brands = join( ", ", $brands );
?>
<p class="beers draught">
<?php printf( esc_html__( \'Brands: <span>%s</span>\', \'textdomain\' ), esc_html( $on_brands ) ); ?>
</p>
<?php endif;
wc_get_template_part( \'content\', \'product\' );
endwhile;
} else {
echo __( \'No results.\' );
}
wp_reset_postdata();
?>
您可以在内容产品中添加其他代码。php模板文件。
您的问题表示要打印术语,但您的初始查询正在尝试筛选结果。如果是:
$args = array(
\'post_type\' => \'product\',
\'posts_per_page\' => -1,
);