Skip to content


Number of Pages vs Number of Archives Shown in WordPress

This issue was bothering me for a long time and now I decided to solve it. My problem was that I couldn’t set the number of entries listed in archive queries. It was the same as number of posts listed per page. Since I usually make long posts, I want to keep this number low. It is set to two now. When only post headers are listed on archive query pages, the small number is very annoying. In WordPress web admin interface I couldn’t find a place to set this value. So I started to dig the sources and found a variable called ‘posts_per_archive_page’ used at several places. I went to the sql database of my blog and checked whether there is a corresponding option variable for this. No luck. Then I decided to make a dirty hack.

I edited the query.php in the wp-includes folder. I looked for the place where the variable is used:

if ( (isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search) )

and inserted the following line before that:

$q['posts_per_archive_page'] = 10;

Eh eh. This is really ugly this way, but works. Now I have 10 entries listed for each query, while the posts per pages is still 2 or whatever I set in the admin interface.

Posted in Blogging tools, tips, tricks.

Tagged with , , , , .