Categories
General

Showing all of an author’s posts on an author archive

One of my family blog authors just noticed that the author archive pages weren’t showing all of an author’s posts. It turns out that the sample author template in the WP Codex that I’d borrowed only shows the number of posts from WordPress’ Settings – in our case 5 posts – and the sample doesn’t include navigation links. Caveat emptor on the Codex examples of course, but even once I noticed the problem it wasn’t all that apparent how to fix it. I wanted to display more (actually all) of an author’s posts because it’d be pretty tedious to use nav links to go through hundreds of posts. After some Codex browsing I figured out that re-doing the query just before the Loop works:

<?php query_posts('author=' . $curauth->ID . '&showposts=-1'); ?>

This is probably running two post queries and highly inefficient, but it does work – I added a little counter to the Loop to double-check.

Avatar photo

By isaac

I like cats. he/him