North Yorkshire Scarborough Website Design UK

How to Limit Archive Links

WordPress Simple 4 Step Tutorial
Posted on 01/30/12 View Comments
Wordpress Limit Archive Widget Fed up with your WordPress Archive Widget getting longer and longer, with no way to limit the output? Well now you have an answer.

We have been asked on many occassions how the WordPress Archive Widget could be limited to output just a few lines, so we decided to upload the solution here.

Follow our Simple 4 Step Process below and you will stop the Archive Widget from taking over your pages, due to so many past posts.

Step 1 – Find the File to Update.

First you need to find the file responsible for limiting your Archive Widget, navigate through your WordPress site or Blog files to the ‘/wp-includes’ folder and then open the ‘default-widgets.php’ file from within this folder.

Step 2 – Locate the Line of Code Requiring Change.

Once you have the file ‘default-widgets.php’ open you will need to find the line of code listed below, you should find this around line 239 of your existing WordPress or Blog code:-
<?php wp_get_archives(apply_filters(‘widget_archives_args’, array(‘type’ => ‘monthly’, ‘show_post_count’ => $c))); ?>

Step 3 – Change The Code to Now Limit Output.

Once you have located the line of code, as above, you now need to change the line of code to the below:-

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

You will notice a new variable ‘limit’ => 5 has been added to signify how many archive posts you want to display, change this ’5′ to whatever number you require your posts limiting to and save the file.

Step 4 – Upload Your Changes.

The final stage is to upload your changed file “default-widgets.php” back to your Website or Blog Server so that the changes can take effect.

You are now done limiting your WordPress Archive Widget.

On viewing your Website or Blog you should now notice that WordPress has Limited the Archive Post Links to the number that you selected above.