akiyum
6/10/2015 - 11:05 AM

子カテゴリーのみを出力(重複を防ぐ)

子カテゴリーのみを出力(重複を防ぐ)

function gl_child_cats($cats_term){
  $cats_id = get_category_by_slug($cats_term)->term_id;
  $args = array('orderby' => 'name', 'order' => 'ASC','child_of' => $cats_id,'hide_empty'=>'0' );
  $categories = get_categories($args);

  echo '<ul>';
  foreach($categories as $category){
  echo '<li id="cat' . $category->term_id . ' " class="subCatNav" "><a href="' . get_category_link( $category->term_id ) . '">' . $category->cat_name . '</a></li>';
  } 
  echo '</ul>';
}