$categories = get_categories( array(
\'parent\' => 0,
) );
foreach ( $categories as $category ) {
echo $category->name;
$posts = get_posts( array(
\'category_name\' => $category->slug,
\'posts_per_page\' => 3,
) );
foreach ( $posts as $item ) {
echo get_the_title( $item->ID );
}
}
你需要这种印刷品。但这是一个非常简单的例子。