我需要一种方法来使用get\\u术语,并让它只获取当前页面的分类法。实例http://sitename.com/genre/hip_hop 只会抓住那些还附加了嘻哈风格的分类法。
wp\\u get\\u object\\u terms几乎适用于我,但不会像get\\u terms那样循环。
这是我现在拥有的
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post();
$cam_brands = get_the_terms( $post->ID, \'sub_genre\' );?>
<?php foreach( $cam_brands as $brand ) : ?>
<h3 class="genre-title"> <?php echo $brand->name; ?> </h3>
<?php $wpq = array( \'post_type\' => \'track\', \'taxonomy\' => \'sub_genre\', \'term\' => $brand->slug, \'post_status\' => \'publish\',\'posts_per_page\' => -1, \'caller_get_posts\'=> 1 );
$brand_posts = new WP_Query ($wpq);?>
<ul>
<?php foreach( $brand_posts->posts as $post ) : ?>
<li> <?php echo $post->post_title; ?> <a class="sc-player" href="<?php echo get(\'soundcloud_link\'); ?>">track</a> </li>
<?php endforeach ?>
</ul>
<?php endforeach ?>
<?php endwhile; ?>
<?php endif; ?>