How you can Restriction the Number of Archive Months Displayed in WordPress?

Do you want to show the number of archive months presented in WordPress? If you have been blogging for years, you will see that your archives listing will end up being also long. In this post, we will show you how you can restrict the variety of archive months showed in WordPress.

Method 1. Restriction Number of Archive Months with Plugin

This approach is less complicated and also it is recommended for all users.

Initial point you need to do is install and turn on the Collapsing Archives plugin. For more details, see our detailed guide on ways to set up a WordPress plugin.

After activation, you have to visit Look” Widgets page as well as include the Collapsing Archives widget to your sidebar.


The widget menu will broaden to reveal its setups.

The Collapsing Archives widget utilizes JavaScript to collapse your archive web links into retractable annual web links. Your individuals can click years to increase them to check out month-to-month archives. You could also make month-to-month archives collapsible and allow customers to see post titles below.

Testimonial the widget settings to fit your needs and afterwards click on the Save button to store your setups.

You could currently see your web site to see the widget in action.


Method 2. Replace Default Archives with Compact Archives

This approach supplies a cleaner option to the default archives widget by wonderfully showing them in a compact more nice means.

Initially, you need to install and activate the Compact Archives plugin.For even more information, see our step by step guide on how you can install a WordPress plugin.

how to install wordpress plugin

After activation, you need to go to Look” Widgets web page and add the ‘Compact Archives’ widget to your sidebar.


Compact Archives plugin is available in 3 styles. You can select from block, initials, or numerical.

Always remember to click the save switch to save your widget settings.

You could currently visit your site to see the portable archives at work.

compactarchives-initials (1)


You could additionally use Compact Archives plugin to create a customized archives page on your website. For more information see our overview on ways to create compact archives in WordPress.

Method 3. By hand Restriction Number of Archive Months in WordPress

This approach needs you to add code to your WordPress motif documents. If you haven’t done this previously, after that have a look at our guide on how to replicate and paste code in WordPress.

You will certainly should include the adhering to code to your theme’s functions.php data or a site-specific plugin.

// Function to get archives list with limited months
function wpb_limit_archives() {

$my_archives = wp_get_archives(array(

return $my_archives;


// Create a shortcode
add_shortcode(‘wpb_custom_archives’, ‘wpb_limit_archives’);

// Enable shortcode execution in text widget
add_filter(‘widget_text’, ‘do_shortcode’);

This code fetches the archives checklist and also restricts it to previous 6 months only. It after that creates a shortcode and also allows shortcode in text widgets.

You could now most likely to Appearance >> Widgets page as well as add a ‘Text’ widget to your sidebar. Switch over to the text setting as well as add your shortcode similar to this:


Do not forget to save your widget setups.

You could currently see your website to see your custom archives listing in action.
That’s all, we hope this article helped you find out ways to limit the variety of archive months showed in WordPress. You may also wish to see our list of these most useful methods for the WordPress functions file.

If you liked this article, then please sign up for our YouTube Network for WordPress video tutorials. You can likewise locate us on Facebook and twitter.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s