Promote your Service and Product online Contact us

+91 87 44 999667; +91 99 11 883996 info@3pixls.com, sales@3pixls.com

Limit the number of months displayed by WordPress archives widget


There is two way to do this job

First

Locate and edit your themes functions.php file. This can either be done in the admin panel by navigating to

you can find

Appearance -> Editor -> Click on functions.php file

or by directly editing the file which you can usually find under

wp-content/themes/<theme name>/functions.php

[php]
function my_limit_archives( $args ) {
$args[‘limit’] = 10;
return $args;
}

add_filter( ‘widget_archives_args’, ‘my_limit_archives’ );
add_filter( ‘widget_archives_dropdown_args’, ‘my_limit_archives’ );
[/php]

Second
Directly add this code, where you want to show archive

[php]
<ul>
<?php wp_get_archives(‘type=monthly’); ?>
</ul>

[/php]

[php]
<ul>
<?php wp_get_archives(‘type=monthly&limit=6’); ?>
</ul>

[/php]