Have wp_get_archives return a string with no year in it

Currently I use wp_get_archives to return the year.

I then call it again with the monthly arg to display the months.

Read More

It displays similarly to this, though I am not sure it will work when we are in a different year:

2011

April 2011(1)

March 2011(12)

I want a display like this

2012(when we reach it)

December(8)

November(5)

2011

April(1)

March(12)

Where the number in brackets is the months post count.

Obviously this means stripping out the year from the monthly archives.
Is this possible? I’d rather not modify core wp functions and do this within the theme, I would also rather not rely on a plugin.

Thank you!

Related posts

Leave a Reply

1 comment

  1. While maybe not the best way to do it, give this a try

    $string = wp_get_archives('type=monthly&limit=20&echo=0');
    $pattern = ' ((19|20)d{2}(</a>))';
    echo preg_replace($pattern, '\3', $string);