Is there any way when using the get archives tag I can group say all of 2001, 2002 and 2003 in an annual archive and then just list entries for 2004 as normal using a monthly list.
Which is the best way of doing it?
I would like to see something like this as well. I don’t know if it’d be easier to set it up so that the past 4 months (or 6 or whatever) were in month format and the rest went to years.
Done. I wrote the script assuming that whatever the current year is, that is the one that you want the months listed underneath. The previous years will simply be links themselves to the archives. Works, or should, with both permalink and normal link structures. Just include the code from:
…and read the instructions listed in there for how to get it working. Let me know if there’s any problems.Anonymous
Thanks for the work! It looks like it almost does exactly what I’m
looking for, but when I run it on my site, the months for 2004 show up
perfectly, but the links for the years themselves return a “Sorry, no
posts matched your criteria.”
Additionally, nothing before 2003 shows up. I don’t know php well enough
to track down this problem, but if you can give me some pointers, I’d be
happy to try to figure it out myself.
Hmmm ok mory…lets track down the root of the problem. First, lets figure out what kind of formatting you want for it’s output, and I’ll work on that. Second, I’ll figure out why it’s not spitting out your year links correctly.
First: I was under the assumption that you wanted the listing setup something like this:
2004 (whatever the currYear is)
Secondly: What kind of link structure are you using? I thought I’d coded my get_year_link() to work on any system, whether perma structure or not, but I might be wrong. So what is the structure to view the year’s full posts on your site.
Additionally: I’ll look into the whole nothing before 2003 thing, but I’m willing to bet it’s because you have the $limit option set … try changing it from 12 to something like…24. 🙂
As far as formatting, that is exactly what I was looking for. I believe I’m set up with permalinks so I’m not sure why it wasn’t grabbing the years properly.
I’m not sure where to look for the $limit option.
the version of my page with the hack is http://blog.morydd.net/index2.php
Where do I exactly add/edit the get_archives_by_year.phps? Sorry I’m just lost.Anonymous
Is this hack available elsewhere? the blindmuse.com links seem to be no good.
@anonymous: blindmuse.com will be back up today … sorry about the site being down, my host sucks the large one. I’ll let you know when it’s up.
I went ahead and turned it into a howto, since I was bored at work. You can check it out at: http://www.blindmuse.com/archive/2004/03/31/group-archives-by-year/ … the howto covers a few other things that I hadn’t mentioned in the other files. Hope that helps iron out any confusion.
Nice hack. Actually, what would be even cooler is, when the user clicks 2002 for example, it would display all the months for 2002 in which an entry exists. Then if the user clicked 2001, it would close the 2002 list and show all the months in 2001 for which an entry exists.
Anything is possible with enough espresso shots.
Without a page reload would be more slick, but I’d settle for either. 😉
Have you had a chance to look any more at how to have the months drop down when a given year is selected in the archives?
Update: I’ve updated one of the functions that is used in the hack, namely the get_year_link(). This update really only affects those users who are not using the permalink structure, but for functinality sake, I suggest everyone make the update.
- The topic ‘Grouping archives by year’ is closed to new replies.