How to Limit the number of Archive months displayed in wordpress?
I got this question over the email. How to limit the number of Archive months displayed in WordPress? It is pretty easy if you read the wordpress documentation. But I will save you some time and show you here. But why do you even need to bother with this?
Well there are some people who like to have archive links in the sidebar because they want their user to browse easily. Then some just want to show how old their blog really is. On the other hand some people absolutely think archives is waste of space on the sidebar. It is too long for older blogs. Well this snippet of code will let you make a compromise. Instead of showing monthly archives like it comes with wordpress default:
<h2>Archives</h2>
<ul>
<?php wp_get_archives(‘type=monthly’); ?>
</ul>
The above codes is built in default wordpress which is fine until the first few months or maybe upto a year. Then you start to get this set of useless links on your sidebar that not everyone visits, so you would have to simply edit the codes and change it like this:
<h2>Archives</h2>
<ul>
<?php wp_get_archives(‘type=monthly&limit=6′); ?>
</ul>
Now this code above will limit your number of archives month displayed on the sidebar to 6. Change the limit number as you please. Now the idea of this is that you have a separate archive page. That contains all the other years and what ever else you want. But the above codes you use to display on the sidebar.
I hope you guys find this useful.





















Hey, I am Syed Balkhi, The guy who is behind Balkhis Inc. I entered the industry back in 2002 not knowing a single thing. I barely spoke English at that time. In the past six years, my language barrier has been eliminated. Aside from English, now I also speak html, and php. Along with the languages I have also managed to master a few arts. Art of web-designing started when I first entered. Messing around with photoshop, I learned how to create my first web design. Now I founded a web designing firm Uzzz Productions. After running numerous amount of websites in various niche, I have mastered the art of web-development. Now I am compiling a resource of what I already know, and what I am learning on this blog. This resource is to help me if I ever need a guide to look back to, and it is help my fellow webmasters.




That’s a nice tutorial
but what’s the use !!!
Good thing Syed, Really a simple thing to manage, but surely will be of use sometime… Thanks for the info again.
Probably, someone will find this useful, but i think it is not good to have archives because of duplicate content. It is fine to use it only if archives are the only categorization on the blog. And in that case this solution would be perfect indeed.
Thanks – this post helped me understand this particular WordPress functionality.