I got the following comment on a previous post:
I love your blog design a lot. I especially *LOVE* your MONTHCHUNKS archives. (It’s tiny, clean and stylish!) Is it possible to post a tutorial on how to achieve that sort of layout? I really really wish to add the same MONTHCHUNKS to my blog :D
The Monthchunks plugin outputs the links to your archives as list items by year, with a link to each month by number:
When you’re viewing a monthly archive page, the number for that month will be bold and not linked. Like the default behavior of
wp_get_archives(), Monthchunks only outputs list items
<li>...</li> for each year. When you call the function, make sure that it’s wrapped in
- Download Monthchunks v2.3 from the WordPress.org Plugin Directory (or from me here)
- Unzip the file and upload the folder
- Activate the plugin
- Edit the theme template file sidebar.php in your theme’s directory:
- Look for this snippet of code:
<ul> <?php wp_get_archives( array( 'type' => 'monthly' ) ); ?> </ul>
and change it to this:
<ul> <?php monthchunks(); ?> </ul>
monthchunks() function can take two optional parameters in between the parentheses.
<?php monthchunks(year_order, month_format); ?>
- year_order is a string (
"ascending") that determines whether the years are displayed in ascending (e.g. 2001, 2002, 2003…) or descending (e.g. 2003, 2002, 2001…) order. The default is descending.
- month_format is a string (
"alpha") that determines whether the month links are printed out as numbers (e.g. 1 2 3 4…) or letters (J F M A…). The default is numeric.
If you wanted to sort the years in ascending order with letters for each month, you’d do this:
<ul> <?php monthchunks("ascending", "alpha"); ?> </ul>
Questions, comments, and suggestions are always welcome. If you’re interested in contributing to the code behind Monthchunks, it’s hosted on GitHub.