WordPress enables a blogger to display their archive by months without any limit placed on the number of archives that can be displayed. Say, you are a blogger and have been running your blog for a long time now, you would have noticed that your blog’s archives list would have become too long which makes it very difficult for a site visitor to explore or browse your old posts.

So, let us learn in this article, that how do we limit the number of archive months and improve visitor experience.

What are archives ?

Archives are extremely helpful since they help the visitors to view content on your blog regardless of the time of its publication. This helps the visitor to browse and find older posts on your blog and hence, promotes visitor engagement. They end up spending more time on your blog. Now, the more time someone spends on your site, greater are the chances of them getting converted.

Search engines like Google and Bing always try to display the latest information or posts on your site. In case, your blog is not very established, then in that case, the content will be displayed on the basis of date. Therefore, archiving is extremely beneficial from SEO (Search Engine Optimization) perspective since it ensures long-term search engine visibility of your blog’s content.

Now, let us understand how to limit the number of archive months.

There are different methods to Limit the Number of Archive Months Displayed in WordPress. I have explained both the methods in detail below:

  1. By using FREE plugin
  2. Without using any plugin.

Method-1: Limit the Number of Archive Months with a FREE Plugin.

Below are the steps:

1. First, you need to install and activate the Compact Archives plugin.

2. Upon activation, go to Appearance » Widgets page.

3. Add the ‘Compact Archives’ widget to your sidebar. This will add the archives to your post sidebar. Review the settings as per your requirements and click on the save button to save your widget settings.

Method-2 Manually Limit the Number of Archive Months in WordPress.

This method requires you to add code to your WordPress theme files in functions.php file.

Always remember, whenever you do any changes to any wordpress core file, do take a backup of your wordpress site, so that you can restore it back in case anything goes wrong.

1. You will need to add the following code

// Function to retrieve the list of archives by limiting it to past 12 months

function month_limit_archives() {

$my_archives = wp_get_archives(array(





return $my_archives;


You can specify the type of archive to retrieve with options being ‘daily’, ‘weekly’, ‘monthly’, ‘yearly’, ‘postbypost’, or ‘alpha’. For eg, if you want to fetch the daily archives of last 2 weeks so, you can specify type daily and limit 14 in the above code.

Now, let us create a shortcode and enable execution of that shortcode.

// Create a shortcode

add_shortcode(‘wpb_custom_archives’, ‘month_limit_archives’);

// Enable shortcode execution in text widget

add_filter(‘widget_text’, ‘do_shortcode’);

2. You can now go to Appearance » Widgets page.

3. Add a ‘Text’ widget to your sidebar. Switch to the text mode and add your shortcode as mentioned below and save your widget settings.


4. Visit your site to see your custom archives list in action.

So the above process illustrates how to manually add the code to limit the number of archive months on your site. You can also implement Method 1 if you are not very familiar with the code.

Would you please post your opinion or queries or feedback below.

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment