<?
//子カテゴリのカテゴリ名を全て取得
$categories = get_terms( 'category', array(
'orderby' => 'count', //投稿数でそーと
'hide_empty' => 1, //0なら投稿がなくても取得、1なら投稿がなければ取得しない
'child_of' => 3, //この親 ID に属する子カテゴリを全て取得する
)
);
foreach($categories as $value) {
echo $value->name; //子カテゴリ名
echo "カテゴリID". $cat_id = $value->term_id; //子カテゴリのID取得
$posts = get_posts('numberposts=0&category='.$cat_id); //カテゴリに属する投稿を取得
global $post; //$postの初期化
if($posts): foreach($posts as $post): setup_postdata($post); //投稿タイトル取得
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?
endforeach; endif;
}
?>