wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

Limit archives widget to display only 12 months

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will limit the archives widget to display only 12 months. Replace the add_filter from the first snippet with the second add_filter bellow so this snippet will work for the dropdown archives widget.

snippet :  PHPcopy
function my_limit_archives($args){
    $args['limit'] = 12;
    return $args;
add_filter( 'widget_archives_args', 'my_limit_archives' );
source →
snippet :  PHP - filter copy
add_filter( 'widget_archives_dropdown_args', 'my_limit_archives' );
source →

Did you like this post? If so please share it with your friends. Thanks!

  • Adrian Robertson

    Thanks! Tried a few other solutions, this is the only one that worked for me. Appreciate it

  • JLT

    Hi, nice snippet.
    Can you just tell me how is it possible to know all vars in the $args parameter?
    I would like to use this code to exclude one category from the archives but I can’t find a documentation page explaining how to use filter args in general.
    Thanks ;)