How To Limit Display Of Archive Months In WordPress

Posted by


Most of the wordpress themes are with standard code to display blog archives by month with no limit to the number of archives to display. Default Code of it as this:

<?php wp_get_archives(‘type=monthly’); ?>

If your blog is well established and you are displaying archive on the page which can drag your page too long which web users does not like. In that case you require to set the limit the months to display the archive. In order to set a rotating limit of months displayed on your blog, you need to make a small change to the above code to add a limit:

Replace the above code with:

<?php wp_get_archives(‘type=monthly&limit=12’); ?>

This will set the limit of last 12 months archive display on the page. You can set the limit according to your requirement.

That’s it!


Shane G.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.