I found a partial answer at: http://floatleft.com/notebook/wordpress-year-month-archives/
This solution shows all months that have posts. Its not even that much code:
<?php
$year_prev = null;
$months = $wpdb->get_results( "SELECT DISTINCT MONTH( post_date ) AS month ,
YEAR( post_date ) AS year,
COUNT( id ) as post_count FROM $wpdb->posts
WHERE post_status = 'publish' and post_date <= now( )
and post_type = 'post'
GROUP BY month , year
ORDER BY post_date DESC");
foreach($months as $month) :
$year_current = $month->year;
if ($year_current != $year_prev){
if ($year_prev != null){?>
</ul>
<?php } ?>
<h3><?php echo $month->year; ?></h3>
<ul class="archive-list">
<?php } ?>
<li>
<a href="<?php bloginfo('url') ?>/<?php echo $month->year; ?>/<?php echo date("m", mktime(0, 0, 0, $month->month, 1, $month->year)) ?>">
<span class="archive-month"><?php echo date("F", mktime(0, 0, 0, $month->month, 1, $month->year)) ?></span>
</a>
</li>
<?php $year_prev = $year_current;
endforeach; ?>
</ul>
My problem is that the designer added all the months, not just the ones that have posts. How could I edit this to show all months, not just the ones with posts. I am using 3.8.1
thanks
The code below will loop through everywhere year and check to see if each month has posts. If so, it will add a link to the month. If not, it will just print the month without a link. You will need to edit the actual link as I am not sure about your websites’ permalink structure.
One solution would be to add the missing months. You have check if all the months of a existent year is present. If not, you add that month with
post_count
zero.