preload

How To Limit Archive Links in The Widget Sidebar

I created this tutorial after being asked several times by different WordPress themers how they can stop the WordPress archives widget from taking over their page, due to so many past posts.

Is your WordPress sidebar getting messy?

Use these steps to limit the number of archive links that appear in your WordPress widget sidebar.

Step 1

Navigate to your /wp-includes folder in your WordPress installation directory and open the default-widgets.php file.

Step 2

Find this line, which is on line 239 in Version 2.9.1:

<?php wp_get_archives(apply_filters(‘widget_archives_args’, array(‘type’ => ‘monthly’, ‘show_post_count’ => $c))); ?>

Step 3

Change that line to:

<?php wp_get_archives(apply_filters(‘widget_archives_args’, array(‘type’ => ‘monthly’, ‘show_post_count’ => $c, ‘limit’ => 5))); ?>

Where , ‘limit’ => 5 is added to signify how many archive posts you want to show.

Step 4

Now upload your default-widgets.php file to the server and check your sidebar!

Done limiting your widget archive listings

You should now only see however many archive posts you limited WordPress to showing.

2 Comments

Doesnt matter 2:07 pm - 11th March:

Hello,

this tip helped me very much. Thx for sharing!

Chris Ullyott 10:31 am - 11th May:

thanks!

Leave a Reply

* Required
** Your Email is never shared