I have a lot of posts/pages, and I would like to create a list in my sidebar, showing all of the years that I have created posts/pages in, so for instance, if I have 5 posts/pages that were spaced out over 5 years, from 2006 to 2011, each year having one post, I would like 2005, 2006, 2007, 2008, 2009, 2010 and 2011 to show as list items in the sidebar, as links to all of the posts/pages created that year.
Any idea of how I can achieve that?
Thanx in advance!
Not sure if there’s a specific function for this as i didn’t find anything with a quick search, but i went ahead and wrote a function to do the job, feel free to expand upon it or do whatever you like with it.
List year archives for published posts of a type
Code is provided “as is”, do as you will with it.
Example usage:
Hope that helps..
There is decent native function
wp_get_archives()
for such, but unfortunately native archives widget doesn’t use all of it and is limited to monthly archives.Take a look at Widgets Reloaded plugin, it replaces native widgets with more configurable versions.