Concisely display monthly archives by year with links to each month.
Display monthly archives by year with links to each month in the following compact format:
2012 1 2 3 4 5 6 7 8 9 2011 1 2 3 4 5 6 7 8 9 10 11 12 2010 6 7 8 9 10 11 12
Serves as a drop in replacement for wp_get_archives( array( 'type' => 'monthly' ) );
.
If you’re interested in contributing to the code behind this plugin, it’s also hosted on GitHub:
https://github.com/justincwatt/wp-monthchunks
wp_get_archives();
with monthchunks();
This is how Monthchunks looks with the Twenty Eleven theme. You can see here that 4 years of archives (eventually 48 links) take up less than 200 vertical pixels of precious sidebar real estate. Note that if you're browsing a monthly archive page, that month's number is emboldened, but not linked. If you hover over the link for any month, you'll see the localized month name and year as a tooltip.
The monthchunks function takes two optional parameters and the first is year_order
, which accepts two string values: "descending"
or "ascending"
.
The monthchunks function takes two optional parameters and the second is month_format
, which accepts three string values: "numeric"
, "alpha"
, or "abbreviation"
. The “alpha” format displays the first letter of the month (e.g. J, F, M…) which may not make sense in all languages. The “abbreviation” format displays the language-specific abbreviation for the month, e.g. (Jan, Feb, Mar…).
title="month_name year"
attribute (aka tooltips) to the month links <ul></ul>
output to make monthchunks more of a drop-in replacement for wp_get_archives()
$wpdb->posts
instead of wp_posts
as table nameget_month_link()
function to output link to monthly archive (thanks raphaƫle)