Compact Archive for WordPress

A much more compact archive: One line for every year; within this line, the list of months with posts

The default WordPress «Archive» block becomes very long and narrow, when months accumulate. Here is an easy way to make it more compact.

The problem

One of my blogs looked like that after a few years of action (wrapped for better visualization; in the original, it is one huge vertical strip):

A long archive list, wrapped in three columns, background colored for structure

The goal

It would be much nicer if it looked like in the heading:

Much nicer, isn’t it?

The code

Here are the code changes in wp-includes/general-template.php (red lines, preceded with a minus, are the lines that I deleted; green with plusses, are the ones I added):

A nice rendering of the file; the actual file can be downloaded here: general-template-compact-archive.patch

If you store this in your /usr/www/wordpress (or wherever you have WordPress installed), then applying the patch on a (Linux, Unix) system is simple:

patch -p1 < general-template-compact-archive.patch

That’s all! patch is an amazing tool, it will look for where this change fits and if there is a fit, it will modify the file accordingly, saving the original with a .orig extension. (If patch thinks aplying the changes is unsafe or something else seems wrong, it will prompt you instead of making anything dangerous.)

Yes, it does require patching one of the default WordPress files. So you need to repeat it after every WordPress (core) upgrade. I wrote that code over four years ago, and all that has happened, is that the code block was moved further down in the file.

So it the loop itself never to be updated during many years. So I think it is safe to assume that this will not constantly break differently in the near future. And even if the code changes: All that happens, is the patch will not be applied, and the boring old archive list will continue to be visible.

Enjoy your new compact Archive!

Let’s stay in touch!

Receive a mail whenever I publish a new post.

About 1-2 Mails per month, no Spam.

Follow me on the Fediverse

Web apps


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.