Home / archives / Limit archives widget to display only 12 months
  • How to Limit archives widget to display only 12 months


    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.

    wordpress snippet : PHP

    function my_limit_archives($args){
        $args['limit'] = 12;
        return $args;
    add_filter( 'widget_archives_args', 'my_limit_archives' );

    wordpress snippet : PHP - filter

    add_filter( 'widget_archives_dropdown_args', 'my_limit_archives' );

    ( WordPress codex functions, hooks, in this snippet. )

    widget_archives_dropdown_args, add_filter,
  • 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 😉