try and test
get_results( “SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = ‘post’ AND post_status = ‘publish’ GROUP BY year DESC” );
foreach ( $years as $year ) {
// get posts for each year
$posts_this_year = $wpdb->get_results( “SELECT post_title FROM wp_posts WHERE post_type = ‘post’ AND post_status = ‘publish’ AND YEAR(post_date) = ‘” . $year->year . “‘” );
echo ‘
‘ . $year->year . ‘
- ‘;
- ‘ . $post->post_title . ‘
foreach ( $posts_this_year as $post ) {
echo ‘
‘;
}
echo ‘
‘;
}
?> There may be room to optimize that, but I’ve tested and it works.