Home > Blog > Limit WordPress archives

Limit WordPress archives

Since switched over to a new theme I needed to rearrange the way the sidebar should look. The list of archives was just to long, think 20 months is the default, to be aesthetic correct. So I started to look for a limit setting in de admin interface of WordPress, but could not find a way to change the limit. I probably looked over it. So browsing through the php scripts I found the file responsible for the way the archives section behaves.

I use WordPress version 2.5.1 from the Debian lenny repository

Edit the following file:

wordpress/wp-includes# vi general-template.php

And look for the following function:

# cat -n general-template.php
<...>
356	function wp_get_archives($args = '') {
357		global $wpdb, $wp_locale;
358
359		$defaults = array(
360			'type' => 'monthly', 'limit' => '<strong>10</strong>',
361			'format' => 'html', 'before' => '',
362			'after' => '', 'show_post_count' => false
363		);
364
<...>
#

Change the options you whish, I lowered the limit to 10 months.

Categories: Blog Tags: ,
  1. Dirk-Jan
    October 17th, 2010 at 12:14 | #1

    Just for the record. I recently upgraded to WordPress 3.0.1, and this customization appears to be still present. It can be found on or around line 867.

  1. No trackbacks yet.