2016/07/02
カスタム投稿
備忘録です。
親タームのみを表示する方法です。
参考サイト
WordPressでカテゴリーやカスタムタクソノミーの親タームのみを出力する方法
<?php $terms = get_the_terms( $post->ID, 'タクソノミー名(カテゴリーの場合はcategory)' ); if ( !empty( $terms ) ) { $output = array(); foreach ( $terms as $term ){ if( 0 == $term->parent ) $output[] = '<a href="' . get_term_link( $term ) .'">' . $term->name . '</a>'; } if( count( $output ) ) echo '' . join( ", ", $output ) . ''; } ?>
2023/06/30
神社
御朱印
2023/06/15
Mac
Linux
2023/04/16
時宗
御朱印
2023/04/14
臨済宗
御朱印
2023/04/05
寺院
御朱印