get_the_category()

【関数】get_the_category( 投稿ID )
現在の投稿が属するカテゴリーの情報を配列として取得する。投稿がカテゴリーに属していない場合は、空の配列を返す。

<?php
  $neko_category_list = get_the_category();  //投稿が属するカテゴリー情報を取得して変数に格納
  if( $neko_category_list ):  //$neko_category_listに値がある場合の条件分岐
?>
//カテゴリー情報の最初のカテゴリー名を取り出して出力する
<li><?php echo esc_html( $neko_category_list[0]->name ); ?> </li>
<?php endif; ?>
inserted by FC2 system