This would be the way I’d do it. Add the following to your functions.php
;
class Walker_Category_Posts extends Walker_Category
{
function start_el( &$output, $category, $depth, $args )
{
parent::start_el( $output, $category, $depth, $args );
if ( $category->parent )
return $output;
if ( $posts = get_posts( 'posts_per_page=-1&no_found_rows=1&update_term_cache=0&cat=" . $category->term_id ) ) {
$output .= "<ul>';
foreach ( $posts as $post )
$output .= '<li><a href="' . get_permalink( $post->ID ) . '">' . apply_filters( 'the_title', $post->post_title ) . '</a></li>';
$output .= '</ul>';
}
}
}
And where you’d like to display the list, call;
<?php wp_list_categories(array('walker' => new Walker_Category_Posts)); ?>