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 ) . '';
}
?>
2026/11/03
AI
2026/11/02
JQuery
css
2026/11/01
車
2026/10/31
神社
御朱印
2026/10/30
AI
Wordpress
AIが書いた原稿をWordPressの「ブロック」に変換して下書きに──Markdownで書かせる理由と、変換で決めた5つのこと