2015/08/10
カスタム投稿
備忘録です。
先日の親タームのみ出力する方法に続いて、子タームのみを表示する方法です。
参考サイト
WordPressで親カテゴリーは出力せずに子カテゴリー(子ターム)のみを出力する方法
子タームのみ出力
<?php
$terms = get_the_terms( $post ->ID, 'タクソノミー名' );
foreach( $terms as $term ) {
if($term->parent){
echo $term->name;
}
}
?>
子カテゴリのみ出力
<?php
$cats = get_the_category();
foreach($cats as $cat){
if($cat->parent){
echo $cat->cat_name;
}
}
?>
2026/11/02
JQuery
css
2026/11/01
車
2026/10/31
神社
御朱印
2026/10/30
AI
Wordpress
AIが書いた原稿をWordPressの「ブロック」に変換して下書きに──Markdownで書かせる理由と、変換で決めた5つのこと
2026/10/29
ホームページ制作
スマートフォン