akiyum
6/10/2015 - 11:04 AM

子カテゴリーのみを出力

子カテゴリーのみを出力

function child_cats(){
  $cats = get_the_category();
  foreach((array)$cats as $cat)
    if($cat->category_parent != 0)
    echo '<li id="cat' . $cat->term_id . '"><a href="' . get_category_link( $cat->term_id ) . '">' . $cat->cat_name . '</a></li>';
}