Limit the number of months displayed by WordPress archives widget
Tweet Follow @3pixelssolutionThere 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]