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. No comments yet.
  1. No trackbacks yet.