投稿ページのカテゴリ名、もしくはターム名を取得
リンク無し
「〇〇〇」はカスタム投稿タイプスラッグ、投稿場合はpostを挿入
<?php
$terms = get_the_terms( $post -> ID, '○○○○' );
foreach ( $terms as $term ){
echo '<h1>'.$term->name.'</h1>';
}
?>
リンクを入れる
「〇〇〇」はカスタム投稿タイプスラッグ、投稿場合はpostを挿入
<?php
$terms = get_the_terms( $post -> ID, '○○○○' );
foreach ( $terms as $term ){
$term_link = get_term_link( $term );
if ( !is_wp_error( $term_link ) ) {
echo '<h1><a href="' . esc_url( $term_link ) . '">' . $term->name . '</a></h1>';
}
}
?>
関連の記事
-
【必見】2015から見るモバイルSEOの進化~昔の常識と最新トレンドを徹底比較!
板浪雅樹
-
実はAppleにもクローラーがあった! Applebotが果たす役割をやさしく解説
板浪雅樹
-
板浪雅樹
-
板浪雅樹
-
板浪雅樹
-
TREVOスタッフ