Getting all months in one year WordPress Archive

How about making an array of months and then getting the posts per-month? Though I suspect this is somewhat less efficient than @Jared’s…

function get_posts_grouped_by_month( $year = null ) {

    if ( $year == null ) {
        $year = date('Y');
    }

    $months = range(1,12);
    $posts = array();

    foreach ( $months as $month ) {
        $posts_for_month = get_posts(array(
            'year' => $year,
            'monthnum' => $month ));
        $posts[$month] = $posts_for_month;
    }

    return $posts;
}

then, in the template:

<?php $monthly_posts = get_posts_grouped_by_month(2011); ?>

<?php foreach ( $monthly_posts as $month => $posts ) { 
    echo "<ul><strong>" . $month . "</strong>\n";   
    foreach ( $posts as $post ) {
        echo "<li>" . get_permalink($post->ID) . "</li>";
    }
    echo "</ul>";
} ?>