カテゴリー
WordPress

【WordPress】タクソノミータームを表示(リンク付)

下記でどうか。

  <?php
$taxonomy = 'タクソノミー名';
$args = array('orderby' => 'term_id', 'order' => 'ASC');
$terms = wp_get_object_terms( $post -> ID, $taxonomy, $args );//ターム取得
if($terms):
foreach ($terms as $term):
$termname = $term -> name;
 $term_link = get_term_link( $term, $taxonomy );//リンク取得
?>
		<?php echo '<a href="' . esc_url( $term_link ) . '">' . esc_html( $termname ) . '</a> ' ;?>
<?php endforeach; endif;?>

※2016/5/11修正

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です