Limit archives widget to display only 12 months

How to Speed Up WordPress - Image optimization

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.

Code Snippet:

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

Code Snippet:

add_filter( 'widget_archives_dropdown_args', 'my_limit_archives' );

Comments  Leave a Reply

  1. 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 😉

  2. Adrian Robertson April 7, 2013 at 10:24 pm

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

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!