• This question has been asked before, but I haven’t been able to locate a great solution. I’m trying to organize archives by year with a link to the archive month page and post count. Something like this:

    2014
    April (12)
    March (1)
    February (8)
    January (3)
    2013
    2012
    2011

    The year would not be a link. It would simply open a drawer containing the months (which would link to the archived month).

    Any help would be much appreciated.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Your best approach would probably revolve around the wp_get_archives() function which basically outputs the HTML you need, though it isn’t quite right.

    You could have the function return the HTML instead of echoing it. You could then write a string manipulation script that locates changes in the year of the month links and inserts the year header, then strips out the years in the link labels for that year.

    Or you can create your own get_archives function based on the applicable source code from the WP version. Thus the output HTML is correct from the beginning.

    As for the “open the drawer” effect, I believe you are describing jQuery UI Accordian, which is included in every WP download, you only need to enqueue the library and setup the archives HTML to use it.

Viewing 1 replies (of 1 total)
  • The topic ‘Archives sorted by year with month subs’ is closed to new replies.