Limit the number of months displayed by WordPress archives widget
Locate and edit your themes functions.php file. This can either be done in the admin panel by navigating to
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
After opening the file simply add the following lines in it.
1 2 3 4 5 6 7 | 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' ); |
Replace the number 10 with the number of months that you want to display and you are done!
There should be a default option. Thank you for the Code. Works perfectly.
Thanks it works for me too.
Worked perfectly…!!!
Thanks for sharing.
great. Thanks!
Another way to do it is directly on sidebar.php if you want it there.
wp_get_archives(‘type=monthly&limit=36’);
I had my doubts about this solution working but to my surprise, it worked great!
THANKS!
This worked great for my Archive. Is there a way I can use this to limit another widget such as the Categories or another widget list of categories?
Many thanks!!!!
This website was… how do I say it? Relevant!! Finally I’ve found something which helped me. Kudos!
Thank you for sharing your info. I really appreciate your efforts and I am waiting for your further post thank you
once again.
Its a shame you dont have a donate button! Id without a doubt donate to this fantastic blog! I suppose for now ill settle for bookmarking and adding your RSS feed to my Google account. I look forward to new updates.